Skip to contents

Wrapper around ggplot2::ggsave() which tries to export plots in a format appropriate for typical report. Only works for plots created by stem_plot_* family of functions.

Usage

stem_ggsave(plot, name = NA, path = NULL, device = "png", dpi = 300)

Arguments

plot

Plot created by stem_plot_*, e.g. stem_plot_bar().

name

Name of exported file, which has to include extension (e.g. ".png"). If NA, will be the same as the plot object (extension not needed then).

path

Optional path to export the plot to.

device

Device to be used for exporting, e.g. "png" or "pdf".

dpi

Resultion of the exported plot. Usually 300 for "medium" resolution, 600 for "high".

Value

File with exported plot.

Details

This function aims at exporting common types of plots in correct size and resolution with minimal user input. Each plot created by stem_plot_* function has plot_fn attribute used to set default width and heigh of the output. For example, plots created by stem_plot_bar() have attribute value of "stem_plot_bar", which leads to them being exported in 16x4 cm dimensions.

Examples

if (FALSE) { # \dontrun{
species_plot <- stem_plot_bar(trust, government)

stem_ggsave(species_plot)
} # }