plotPNG {shiny} | R Documentation |
Capture a plot as a PNG file.
Description
The PNG graphics device used is determined in the following order:
If the ragg package is installed (and the
shiny.useragg
is not set toFALSE
), then useragg::agg_png()
.If a quartz device is available (i.e.,
capabilities("aqua")
isTRUE
), then usepng(type = "quartz")
.If the Cairo package is installed (and the
shiny.usecairo
option is not set toFALSE
), then useCairo::CairoPNG()
.Otherwise, use
grDevices::png()
. In this case, Linux and Windows may not antialias some point shapes, resulting in poor quality output.
Usage
plotPNG(
func,
filename = tempfile(fileext = ".png"),
width = 400,
height = 400,
res = 72,
...
)
Arguments
func |
A function that generates a plot. |
filename |
The name of the output file. Defaults to a temp file with
extension |
width |
Width in pixels. |
height |
Height in pixels. |
res |
Resolution in pixels per inch. This value is passed to the graphics device. Note that this affects the resolution of PNG rendering in R; it won't change the actual ppi of the browser. |
... |
Arguments to be passed through to the graphics device. These can be used to set the width, height, background color, etc. |
Details
A NULL
value provided to width
or height
is ignored (i.e., the
default width
or height
of the graphics device is used).
Value
A path to the newly generated PNG file.