add_emoji: Input an emoji and create a ggplot2 layer to add to an...

View source: R/add_emoji.R

add_emojiR Documentation

Input an emoji and create a ggplot2 layer to add to an existing plot

Description

Input an emoji and create a ggplot2 layer to add to an existing plot

Usage

add_emoji(emoji, x = NULL, y = NULL, ysize = NULL)

Arguments

emoji

either a codepoint (without \U etc), or the result from emoji_search

x

x value of the emoji center. Ignored if y and ysize are not specified.

y

y value of the emoji center. Ignored if x and ysize are not specified.

ysize

Height of the emoji. The width is determined by the aspect ratio of the original image. Ignored if x and y are not specified.

Details

Use parameters x, y, and ysize to place the emoji at a specified position on the plot. If all three of these parameters are unspecified, then the emoji will be plotted to the full height and width of the plot.

Note

Based on add_phylopic from rphylopic by Scott Chamberlain.

Examples

## Not run: 
library(ggplot2)
library(emoGG)

# Put an emoji anywhere
posx <- runif(50, 0, 10)
posy <- runif(50, 0, 10)
sizey <- runif(50, 0.4, 2)
p <- ggplot(data.frame(x = posx, y = posy), aes(x, y)) +
            geom_point(color = rgb(0,0,0,0))
for (i in 1:50) {
  p <- p + add_emoji("1f697", posx[i], posy[i], sizey[i])
}
p

## End(Not run)

dill/emoGG documentation built on Feb. 3, 2023, 6:57 a.m.