Learn R Programming

ggreveal (version 0.1.3)

reveal_save: Saves incremental plots

Description

Saves incremental plots

Usage

reveal_save(plot_list, basename, ...)

Value

The paths of the saved plots, invisibly

Arguments

plot_list

A list of plots created by one of the reveal_* functions (e.g. reveal_groups(), reveal_layers(), reveal_aes()]

basename

The base file name that will be used for saving.

...

Additional arguments (e.g. width, height) to be passed to ggplot2::ggsave()

Examples

Run this code
# Create full plot
library(ggplot2)
data("mtcars")

p <- mtcars |>
  ggplot(aes(mpg, wt,
             color = factor(vs),
             group = factor(vs))) +
  geom_point() +
  geom_smooth(method="lm",
              formula = 'y ~ x',
              linewidth=1) +
  facet_wrap(~am)
p

plot_list <- reveal_groups(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)) 

Run the code above in your browser using DataLab