thematic (version 0.1.1)

thematic_save_plot: Capture a thematic plot as a saved file

Description

Uses a device to capture the result of an expression (expr) that produces a plot. If default_device() is used, custom fonts (specified through font_spec()) are guaranteed to work, as long as one of either the showtext or ragg package(s) are installed.

Usage

thematic_save_plot(
  expr,
  device = default_device(),
  filename = tempfile(fileext = ".png"),
  ...
)

default_device(type = c("png", "svg", "pdf", "tiff", "jpeg"))

Arguments

expr

an expression that produces a plot.

device

a graphics device to use for capturing the plot.

filename

a filename for the produced plot. The file extension should match the relevant device.

...

arguments passed along to the graphics device.

type

the type of output format

Value

thematic_save_plot() returns the filename of the produced plot and default_device() returns a graphics device function.

Examples

Run this code
# NOT RUN {
library(thematic)
font <- font_spec("Rock Salt", scale = 1.25)
thematic_on("black", "white", font = font)
file <- thematic_save_plot(plot(1:10), res = 144)
if (interactive()) browseURL(file)
# }

Run the code above in your browser using DataCamp Workspace