reveal_x {ggreveal} | R Documentation |
Reveal plot by axis
Description
Turns a ggplot into a list of plots, showing data incrementally by the categories in the x or y axis.
Usage
reveal_x(p, order = NULL)
reveal_y(p, order = NULL)
Arguments
p |
A ggplot2 object |
order |
(optional) A numeric vector specifying in which order to reveal the categories For example, if there are three categories in the axis, Any category not included in the vector will be omitted from the incremental
plots. E.g.: with By default, the first plot is blank, showing layout elements (title,
legends, axes, etc) but no data. To omit the blank plot, include |
Value
A list of ggplot2 objects, which can be passed to reveal_save()
Examples
# Create full plot
library(ggplot2)
data("mtcars")
p <- mtcars |>
ggplot(aes(factor(vs),
color = gear,
fill= gear,
group = gear)) +
geom_bar() +
facet_wrap(~am)
p
plot_list <- reveal_x(p)
plot_list[[1]]
plot_list[[2]]
plot_list[[3]]
# Save plots
reveal_save(plot_list, "myplot.png", width = 8, height = 4, path = tempdir())
# Clean temp files
file.remove(list.files(path = tempdir(), pattern = "myplot", full.names = TRUE))
[Package ggreveal version 0.1.3 Index]