View source: R/ggplot_box_legend.R
ggplot_box_legend | R Documentation |
Create a legend that explains the features of a boxplot. Can be added easily
to existing ggplots using plot_grid
or plot_arithmetic
.
ggplot_box_legend(
font_family = "OpenSansCondensed_TWRI",
point_label = " - Measured values"
)
font_family |
defaults to |
point_label |
character string - how you want to label to point in a
legend. If you overlay measured points in the box plot, |
a ggplot object
Laura DeCicco
https://waterdata.usgs.gov/blog/boxplots/
library(ggplot2)
library(cowplot)
ggplot(dissolved_oxygen) +
geom_boxplot(aes(as.factor(station_id),
average_do,
group = station_id)) +
geom_jitter(aes(as.factor(station_id),
average_do,
group = station_id),
width = 0.1, alpha = 0.25) +
theme_TWRI_print() -> p1
file <- tempfile(fileext = '.png')
ragg::agg_png(file)
plot_grid(p1, ggplot_box_legend(), rel_widths = c(2,1))
dev.off()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.