View source: R/ggsave_vbracket.R
| ggsave_vbracket | R Documentation |
This function is a wrapper around ggsave() that properly handles vbracket legends. Use this instead of ggsave() when your plot has a legend_bracket().
ggsave_vbracket(
filename,
plot,
device = NULL,
width = NA,
height = NA,
units = c("in", "cm", "mm", "px"),
dpi = 300,
...
)
filename |
File name to save plot to |
plot |
Plot to save (must have legend_bracket) |
device |
Device to use (default auto-detects from filename) |
width |
Width in units |
height |
Height in units |
units |
Units for width and height ("in", "cm", "mm", "px") |
dpi |
DPI for raster devices |
... |
Additional arguments passed to ggsave() |
No return value, called for its side effects. Saves the plot (including the vbracket legend, if present) to the file specified by filename.
library(ggplot2)
data <- data.frame(x = 1:10, y = 1:10, group = rep(c("A", "B"), each = 5))
labels <- c("A", "B")
colors <- c("A" = "red", "B" = "blue")
comparisons <- add_bracket_comparisons(groups1 = "A", groups2 = "B", labels = "*")
p <- ggplot(data, aes(x, y, color = group)) +
geom_point() +
legend_bracket(labels, colors, comparisons,
position = "topleft", output_width = 6, output_height = 4)
ggsave_vbracket(file.path(tempdir(), "plot.pdf"), p, width = 6, height = 4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.