geom_custom: geom_custom

Description Usage Arguments Value Examples

View source: R/geom_custom.r

Description

Draw user-defined grobs, typically annotations, at specific locations.

Usage

1
geom_custom(mapping = NULL, data = NULL, inherit.aes = TRUE, ...)

Arguments

mapping

mapping

data

data

inherit.aes

inherit.aes

...

arguments passed to the geom's draw_group method

Value

layer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library(grid)
d <- data.frame(x=rep(1:3, 4), f=rep(letters[1:4], each=3))
gl <- replicate(4, matrix(sample(palette(), 9, TRUE), 3, 3), FALSE)
dummy <- data.frame(f=letters[1:4], data = I(gl))
ggplot(d, aes(f,x)) +
  facet_wrap(~f)+
  theme_bw() +
  geom_point()+
  geom_custom(data = dummy, aes(data = data, y = 2),
              grob_fun = function(x) rasterGrob(x, interpolate = FALSE,
                                                width=unit(1,'cm'),
                                                height=unit(1,'cm')))

baptiste/egg documentation built on May 30, 2021, 1:24 a.m.