View source: R/alignpatch-wrap.R
ggwrap | R Documentation |
The ggwrap()
function allows non-ggplot2 elements to be converted into a
compliant representation for use with align_plots()
. This is useful for
adding any graphics that can be converted into a grob
with
the patch()
method.
ggwrap(plot, ..., align = "panel", on_top = FALSE, clip = TRUE, vp = NULL)
plot |
Any graphic that can be converted into a |
... |
Additional arguments passed to the |
align |
A string specifying the area to place the plot: |
on_top |
A single boolean value indicates whether the graphic plot should be put frontmost. Note: the graphic plot will always put above the background. |
clip |
A single boolean value indicating whether the grob should be clipped if they expand outside their designated area. |
vp |
A |
A wrapped_plot
object that can be directly placed into
align_plots()
.
library(grid)
ggwrap(rectGrob(gp = gpar(fill = "goldenrod")), align = "full") +
inset(rectGrob(gp = gpar(fill = "steelblue")), align = "panel") +
inset(textGrob("Here are some text", gp = gpar(color = "black")),
align = "panel"
)
p1 <- ggplot(mtcars) +
geom_point(aes(mpg, disp)) +
ggtitle("Plot 1")
align_plots(p1, ggwrap(
~ plot(mtcars$mpg, mtcars$disp),
mar = c(0, 2, 0, 0), bg = NA
))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.