Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions R/geom_emoji.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#'
#' Use emoji as you would \code{\link{geom_point}}.
#'
#' The \code{size} aesthetic controls the emoji width and height in millimetres.
#'
#' @author David L Miller
#' @importFrom proto proto
#' @importFrom grid rasterGrob grobTree
Expand All @@ -18,7 +20,7 @@
#'
#' # plot the data, but with emojis
#' ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
#' geom_emoji(emoji="1f337")
#' geom_emoji(emoji="1f337", size = 12)
#'
#'}
geom_emoji <- function(mapping = NULL, data = NULL, stat = "emoji",
Expand Down Expand Up @@ -63,8 +65,8 @@ emojisGrob <- function(coords){
y = y,
image = emoji,
default.units = "native",
height = size,
width = size)
height = unit(size, "mm"),
width = unit(size, "mm"))
}
ff <- function(coords){
raster_it(coords$x, coords$y, coords$size, coords$emoji)
Expand Down
6 changes: 3 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ The `iris` example with **real** irises (well, tulips...)

```{r iris_ex, fig.height=4, fig.width=4}
ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
geom_emoji(emoji="1f337")
geom_emoji(emoji="1f337", size = 6)
```

What about plotting `mtcars` with **real** cars?

```{r mtcars, fig.height=4, fig.width=4}
ggplot(mtcars, aes(wt, mpg))+ geom_emoji(emoji="1f697")
ggplot(mtcars, aes(wt, mpg))+ geom_emoji(emoji="1f697", size = 6)
```

Want to map `emoji` as an aesethetic? [Check out this gist](https://gist.github.com/dill/28bb04fc35b51326f01b23d078f5021e)!
Expand All @@ -57,7 +57,7 @@ Some random cats?
```{r, catplotlib, fig.height=4, fig.width=4}
posx <- runif(50, 0, 10)
posy <- runif(50, 0, 10)
ggplot(data.frame(x = posx, y = posy), aes(x, y)) + geom_emoji(emoji="1f63b")
ggplot(data.frame(x = posx, y = posy), aes(x, y)) + geom_emoji(emoji="1f63b", size = 6)
```

We can also just put a big emoji in the background:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,21 @@ look for a tulip:
The `iris` example with **real** irises (well, tulips...)

ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
geom_emoji(emoji="1f337")
geom_emoji(emoji="1f337", size = 6)

![](figure/iris_ex-1.png)

What about plotting `mtcars` with **real** cars?

ggplot(mtcars, aes(wt, mpg))+ geom_emoji(emoji="1f697")
ggplot(mtcars, aes(wt, mpg))+ geom_emoji(emoji="1f697", size = 6)

![](figure/mtcars-1.png)

Some random cats?

posx <- runif(50, 0, 10)
posy <- runif(50, 0, 10)
ggplot(data.frame(x = posx, y = posy), aes(x, y)) + geom_emoji(emoji="1f63b")
ggplot(data.frame(x = posx, y = posy), aes(x, y)) + geom_emoji(emoji="1f63b", size = 6)

![](figure/catplotlib-1.png)

Expand Down
4 changes: 3 additions & 1 deletion man/geom_emoji.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.