Saves a ggplot with sizes matching common two-column conference/journal
layouts (e.g., ACM): a single-column figure is 3.33 in wide, a full-width
figure 7 in. On Windows and Linux, PDFs are rendered with
grDevices::cairo_pdf so that fonts are embedded and unicode glyphs
survive; on macOS the default pdf device is used instead, because R's
cairo on macOS is known to crash some setups (e.g., GitHub Actions
runners) and the macOS device handles fonts well on its own.
Usage
save_paper_figure(
plot = ggplot2::last_plot(),
filename,
columns = 1,
width = NULL,
height = NULL,
base_size = NULL,
dpi = 300,
device = NULL
)Arguments
- plot
The plot to save (defaults to the last plot displayed).
- filename
Output path; the extension selects the device (
.pdfis recommended for LaTeX).- columns
1 for a single-column figure, 2 for a full-width figure. Ignored when
widthis given.- width
Figure width in inches; overrides
columns.- height
Figure height in inches. Defaults to 2/3 of the width.
- base_size
Base font size in points for the saved figure, applied via
colley_theme()sizing on top of whatever theme the plot carries. The defaultNULLderives it fromwidth, so a 3.33 in figure gets about 7 pt and a 7 in figure about 9 pt – close to the body text of a typical two-column paper, which is what makes a figure legible at 100\ rather than only when zoomed. Pass a number to choose it yourself, orNAto leave the plot's own text sizes untouched.- dpi
Resolution for raster output. Default 300.
- device
Graphics device passed to
ggplot2::ggsave(). The defaultNULLselects it automatically as described above; pass e.g.grDevices::cairo_pdfexplicitly to override.