View source: R/ggplot-geom-draw.R
geom_draw | R Documentation |
Draw a ggplot2 layer using a grob or a function.
geom_draw(
draw,
mapping = NULL,
data = NULL,
type = "group",
stat = "identity",
position = "identity",
...,
na.rm = FALSE,
show.legend = FALSE,
inherit.aes = TRUE
)
draw |
Either a grob object or a function (can be purrr-style) that accepts at least one argument (a data frame of transformed coordinates) and returns a grob. |
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
type |
A single string of |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
If you want to combine the functionality of multiple geoms, it can
typically be achieved by preparing the data for each geom inside the
draw_*()
call and sending it off to the different geoms, collecting the
output in a grid::gList
(a list of grobs) for draw_group()
or a
grid::gTree
(a grob containing multiple child grobs) for
draw_panel()
.
https://ggplot2.tidyverse.org/reference/ggplot2-ggproto.html
text <- grid::textGrob(
"ggdraw",
x = c(0, 0, 0.5, 1, 1),
y = c(0, 1, 0.5, 0, 1),
hjust = c(0, 0, 0.5, 1, 1),
vjust = c(0, 1, 0.5, 0, 1)
)
ggplot(data.frame(x = 1, y = 2)) +
geom_draw(text)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.