Skip to contents

Compiles a PlotSpec into a vellum::vl_scene() and writes it. The output format is taken from the file extension (.png, .svg, .pdf). vellum::render() also works on a plot directly, dispatching through the as_vellum_scene() seam.

Usage

render_plot(plot, path, text = "native", dpi = NULL)

Arguments

plot

A PlotSpec.

path

Output file path.

text

For SVG output, how text is written (see vellum::render()).

dpi

Output resolution in dots per inch. NULL (default) uses the plot's authored resolution (set on vplot()); a number overrides it for this render, so the PNG's pixel dimensions become width * dpi by height * dpi. Ignored for .svg/.pdf, which are resolution-independent.

Value

path, invisibly.

Examples

p <- vplot(mtcars) |> mark_point(x = wt, y = mpg)
f <- tempfile(fileext = ".png")
render_plot(p, f)
render_plot(p, f, dpi = 300) # denser raster, same physical size