insert_layer | R Documentation |
insert_layer()
insert layers to an arbitrary position
mean_sd()
calculates mean and sd for ggplot2::stat_summary()
.
label_none()
removes strip.text
while keeping strip.background
.
insert_layer(p, ..., after = 0L)
mean_sd(x, mult = 1)
label_none(labels, ...)
p |
gg object |
... |
layers to add |
after |
position; 0L is back |
x |
numeric vector. |
mult |
number of multiples of standard error. |
labels |
Data frame of labels. Usually contains only one element, but faceting over multiple factors entails multiple label variables. |
(ggplot2::ggplot(ggplot2::mpg) +
ggplot2::aes(drv, hwy) +
ggplot2::geom_boxplot(fill = "gold") +
ggplot2::geom_dotplot(binaxis = "y", stackdir = "center", binwidth = 1, stackratio = 0.5) +
ggplot2::stat_summary(fun.data = mean_sd, color = "red", size = 2, linewidth = 2) +
ggplot2::facet_wrap(ggplot2::vars(drv), scale = "free_x", label = label_none)) |>
insert_layer(ggplot2::geom_violin(fill = "darkorange"), after = -2L)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.