Skip to contents

A wrapper around ggplot2::ggsave() that saves plots with layout profiles optimized for slides and publications.

Usage

nice_save(
  filename,
  plot = ggplot2::last_plot(),
  layout = c("full col", "half col", "tiny", "full page", "slides"),
  custom = NULL,
  ...
)

Arguments

filename

Name of the file to save. Should end in .png, .tiff, .pdf, .svg, etc.

plot

A ggplot object. If omitted, uses the last plot.

layout

One of: "full col", "half col", "tiny", "full page", "slides".

custom

A vector of width and height in inches. If specified, will override layout

...

Additional arguments passed to ggplot2::ggsave().

Value

Saves the plot and returns the filename (invisibly).

Details

Supported layouts:

  • "full col" (3.6 in): Standard full-column publication figure

  • "half col" (1.8 in): Half-width column figure

  • "tiny" (1 in): For compact sub-figures or thumbnails

  • "full page" (7.2 in): Full-page width figure

  • "slides" (4.4 in height): For presentation slides

For optimal rendering, adjust font_size in theme_charite() and control sizes and margins in your plot. Recommended sizes: 6 or 8 pt for most plots, 6 pt or smaller for "tiny" plots; 10 or 12 pt for "slides".

A note on fonts: System-installed fonts like Helvetica usually behave much better in vector graphics export than non-standard fonts like Calibri or in-house fonts.

Plots rendered with theme_charite() have transparent backgrounds. You may override with bg = "white". For publication-ready figures, .pdf is the preferred publication vector format. Saving to .svg requires the svglite package. SVG font rendering may vary across platforms and viewers, especially for non-standard fonts such as Calibri.

Examples

if (FALSE) { # \dontrun{
nice_save("example.png", example_plot())
} # }