The PNG graphics device used is determined in the following order:

  • If the ragg package is installed (and the shiny.useragg is not set to FALSE), then use ragg::agg_png().

  • If a quartz device is available (i.e., capabilities("aqua") is TRUE), then use png(type = "quartz").

  • If the Cairo package is installed (and the shiny.usecairo option is not set to FALSE), then use Cairo::CairoPNG().

  • Otherwise, use grDevices::png(). In this case, Linux and Windows may not antialias some point shapes, resulting in poor quality output.

  filename = tempfile(fileext = ".png"),
  width = 400,
  height = 400,
  res = 72,



A function that generates a plot.


The name of the output file. Defaults to a temp file with extension .png.


Width in pixels.


Height in pixels.


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.


A path to the newly generated PNG file.


A NULL value provided to width or height is ignored (i.e., the default width or height of the graphics device is used).