| Title: | Draw with 'grid' in 'ggplot2' |
|---|---|
| Description: | An extension of 'ggplot2' that makes it easy to add raw 'grid' output, such as customised annotations, to a 'ggplot2' plot. |
| Authors: | Paul Murrell [aut, cre] |
| Maintainer: | Paul Murrell <[email protected]> |
| License: | GPL-3 |
| Version: | 0.2-1 |
| Built: | 2026-05-28 10:24:35 UTC |
| Source: | https://github.com/pmur002/gggrid |
Adds a layer to a ggplot2 plot based on a raw grid grob or on a function that generates a 'grid' grob.
grid_panel(grob = nullGrob(), mapping = NULL, data = NULL, stat = "identity", position = "identity", inherit.aes = TRUE, show.legend = FALSE, key_glyph = NULL, debug = NULL, ...) grid_group(grob = nullGrob(), mapping = NULL, data = NULL, stat = "identity", position = "identity", inherit.aes = TRUE, show.legend = FALSE, key_glyph = NULL, debug = NULL, ...)grid_panel(grob = nullGrob(), mapping = NULL, data = NULL, stat = "identity", position = "identity", inherit.aes = TRUE, show.legend = FALSE, key_glyph = NULL, debug = NULL, ...) grid_group(grob = nullGrob(), mapping = NULL, data = NULL, stat = "identity", position = "identity", inherit.aes = TRUE, show.legend = FALSE, key_glyph = NULL, debug = NULL, ...)
grob |
Either a grid grob or a function. The function must accept
two arguments ( |
mapping, data, stat, position, inherit.aes
|
Standard arguments to a ggplot2 Geom. |
debug |
Either |
show.legend |
Logical indicating whether |
key_glyph |
A function to draw the key glyph in the legend. |
... |
Other arguments passed on to |
The grid_panel() function will draw the grob, or call the
grob function, once for each ggplot2 panel.
The grid_group() function will draw the grob, or call the
grob function, once for each ggplot2 group.
When adding a key_glyph, the call to grid_panel() or
grid_group() must include an explicit mapping.
Paul Murrell
tg <- textGrob("label", x=unit(1, "npc") - unit(2, "mm"), y=unit(1, "npc") - unit(2, "mm"), just=c("right", "top")) ggplot(mtcars) + geom_point(aes(disp, mpg)) + grid_panel(tg)tg <- textGrob("label", x=unit(1, "npc") - unit(2, "mm"), y=unit(1, "npc") - unit(2, "mm"), just=c("right", "top")) ggplot(mtcars) + geom_point(aes(disp, mpg)) + grid_panel(tg)