Package 'ggimage'

Title: Use Image in 'ggplot2'
Description: Supports image files and graphic objects to be visualized in 'ggplot2' graphic system.
Authors: Guangchuang Yu [aut, cre]
Maintainer: Guangchuang Yu <[email protected]>
License: Artistic-2.0
Version: 0.3.3
Built: 2024-11-01 04:24:41 UTC
Source: https://github.com/guangchuangyu/ggimage

Help Index


autocomplete_name

Description

obtaion suggestions for full names based on partial text name

Usage

autocomplete_name(name, ...)

Arguments

name

partial text name

...

additional parameters

Value

scientific name


download_phylopic

Description

download phylopic images

Usage

download_phylopic(id, destdir = ".", ...)

Arguments

id

phylopic id

destdir

directory where the downloaded images are to be saved.

...

additional parameters passed to download.file

Details

This function allows users to download phylopic images using phylopic id

Value

a character string (or vector) with downloaded file path

Author(s)

Guangchuang Yu


key drawing function

Description

key drawing function

Usage

draw_key_image(data, params, size)

Arguments

data

A single row data frame containing the scaled aesthetics to display in this key

params

A list of additional parameters supplied to the geom.

size

Width and height of key in mm

Value

A grid grob


geom_bgimage

Description

add image as background to plot panel.

Usage

geom_bgimage(image)

Arguments

image

image file

Value

ggplot

Author(s)

Guangchuang Yu


geom_emoji

Description

geom layer for using emoji image

Usage

geom_emoji(
  mapping = NULL,
  data = NULL,
  inherit.aes = TRUE,
  na.rm = FALSE,
  by = "width",
  ...
)

Arguments

mapping

aes mapping

data

data

inherit.aes

whether inherit aes mapping from ggplot()

na.rm

whether remove NA values

by

one of 'width' or 'height' for specifying size

...

additional parameter

Value

ggplot2 layer

Author(s)

Guangchuang Yu


geom_flag

Description

geom layer for using flag image

Usage

geom_flag(
  mapping = NULL,
  data = NULL,
  inherit.aes = TRUE,
  na.rm = FALSE,
  by = "width",
  ...
)

Arguments

mapping

aes mapping

data

data

inherit.aes

whether inherit aes mapping from ggplot()

na.rm

whether remove NA values

by

one of 'width' or 'height' for specifying size

...

additional parameter

Value

ggplot2 layer

Author(s)

Guangchuang Yu


geom_icon

Description

geom layer for using icon

Usage

geom_icon(
  mapping = NULL,
  data = NULL,
  inherit.aes = TRUE,
  na.rm = FALSE,
  by = "width",
  ...
)

Arguments

mapping

aes mapping

data

data

inherit.aes

whether inherit aes mapping from ggplot()

na.rm

whether remove NA values

by

one of 'width' or 'height' for specifying size

...

additional parameter

Value

ggplot2 layer

Author(s)

guangchuang yu


geom_image

Description

geom layer for visualizing image files

Usage

geom_image(
  mapping = NULL,
  data = NULL,
  stat = "identity",
  position = "identity",
  inherit.aes = TRUE,
  na.rm = FALSE,
  by = "width",
  nudge_x = 0,
  ...
)

Arguments

mapping

aes mapping

data

data

stat

stat

position

position

inherit.aes

logical, whether inherit aes from ggplot()

na.rm

logical, whether remove NA values

by

one of 'width' or 'height'

nudge_x

horizontal adjustment to nudge image

...

additional parameters

Value

geom layer

Author(s)

Guangchuang Yu

Examples

## Not run: 
library("ggplot2")
library("ggimage")
set.seed(2017-02-21)
d <- data.frame(x = rnorm(10),
                y = rnorm(10),
                image = sample(c("https://www.r-project.org/logo/Rlogo.png",
                                "https://jeroenooms.github.io/images/frink.png"),
                              size=10, replace = TRUE)
               )
ggplot(d, aes(x, y)) + geom_image(aes(image=image))

## End(Not run)

geom_phylopic

Description

geom layer for using phylopic image

Usage

geom_phylopic(
  mapping = NULL,
  data = NULL,
  inherit.aes = TRUE,
  na.rm = FALSE,
  by = "width",
  ...
)

Arguments

mapping

aes mapping

data

data

inherit.aes

whether inherit aes mapping from ggplot()

na.rm

whether remove NA values

by

one of 'width' or 'height' for specifying size

...

additional parameter

Value

ggplot2 layer

Author(s)

Guangchuang Yu


geom_pokemon

Description

geom layer for using pokemon image

Usage

geom_pokemon(
  mapping = NULL,
  data = NULL,
  inherit.aes = TRUE,
  na.rm = FALSE,
  by = "width",
  ...
)

Arguments

mapping

aes mapping

data

data

inherit.aes

whether inherit aes mapping from ggplot()

na.rm

whether remove NA values

by

one of 'width' or 'height' for specifying size

...

additional parameter

Value

ggplot2 layer

Author(s)

guangchuang yu


geom_subview

Description

subview geom

Usage

geom_subview(
  mapping = NULL,
  data = NULL,
  width = 0.1,
  height = 0.1,
  x = NULL,
  y = NULL,
  subview = NULL
)

Arguments

mapping

aes mapping, requires 'x', 'y' and 'subview'

data

data frame

width

width

height

height

x

x position of subview. This parameter works if mapping and data is not provided

y

y position of subview. This parameter works if mapping and data is not provided

subview

subview to plot, if not provided in data and specify by mapping

Value

layer

Author(s)

guangchuang yu


geom_twitchemotes

Description

geom layer for using Twitch emotes

Usage

geom_twitchemote(
  mapping = NULL,
  data = NULL,
  inherit.aes = TRUE,
  na.rm = FALSE,
  by = "width",
  ...
)

Arguments

mapping

aes mapping

data

data

inherit.aes

whether inherit aes mapping from ggplot()

na.rm

whether remove NA values

by

one of 'width' or 'height' for specifying size

...

additional parameter

Value

ggplot2 layer

Author(s)

Brendan Rocks


geom_worldcup2018

Description

geom layer for wordcup 2018

Usage

geom_worldcup2018(
  mapping = NULL,
  data = NULL,
  inherit.aes = TRUE,
  na.rm = FALSE,
  by = "width",
  ...
)

Arguments

mapping

aes mapping

data

data

inherit.aes

whether inherit aes mapping from ggplot()

na.rm

whether remove NA values

by

one of 'width' or 'height' for specifying size

...

additional parameter

Value

ggplot2 layer

Author(s)

Guangchuang Yu


ggbackground

Description

set background for ggplot

Usage

ggbackground(gg, background, ...)

Arguments

gg

gg object

background

background image

...

additional parameter to manipulate background image, see also geom_image

Value

gg object

Author(s)

guangchuang yu


ggpreview

Description

preview a plot befor saving it to a file.

Usage

ggpreview(
  filename = NULL,
  plot = last_plot(),
  width = NA,
  height = NA,
  units = "in",
  ...
)

Arguments

filename

If it is not NULL, the previewed figure will be save to the file

plot

any plot that supported by the 'ggplotify' package

width

width of the figure

height

height of the figure

units

units of the 'width' and 'height'

...

additional parameters pass to ggsave() if filename is not NULL

Value

a preview of the figure

Author(s)

Guangchuang Yu


image_read2

Description

read image (by magick::image_read) with the ability to remove marginal empty space

Usage

image_read2(path, ..., cut_empty_space = TRUE)

Arguments

path

file path

...

additional parameters that pass to magick::image_read

cut_empty_space

whether remove marginal empty space

Value

magick-image object

Author(s)

Guangchuang Yu


list.flag

Description

list available flag

Usage

list.flag()

Value

flag vector

Author(s)

Guangchuang Yu


list.icon

Description

list available icon

Usage

list.icon()

Value

icon vector

Author(s)

guangchuang yu


list.pokemon

Description

list available pokemon

Usage

list.pokemon()

Value

pokemon vector

Author(s)

guangchuang yu


list.worldcup2018

Description

list flags of worldcup 2018

Usage

list.worldcup2018()

Value

flag vector

Author(s)

Guangchuang Yu


phylopic_uid

Description

query phylopic to get uid from scientific name

Usage

phylopic_uid(name, seed = 123)

Arguments

name

scientific name

seed

The random seed to use to generate the same uid, because a name might have many uid, the function will extract one of them randomly, default is 123.

Value

phylopic uid

Author(s)

Guangchuang Yu


theme_nothing

Description

A theme that only show the plot panel

Usage

theme_nothing(base_size = 11, base_family = "")

Arguments

base_size

font size

base_family

font family

Value

ggplot2 theme

Author(s)

Guangchuang Yu


theme_transparent

Description

transparent background theme

Usage

theme_transparent(...)

Arguments

...

additional parameter to tweak the theme

Value

ggplot object

Author(s)

Guangchuang Yu with contributions from Hugo Gruson