Graphics devices for SVG, PDF and PostScript graphics files using the cairo graphics API.
svg(filename = if(onefile) "Rplots.svg" else "Rplot%03d.svg", width = 7, height = 7, pointsize = 12, onefile = FALSE, family = "sans", bg = "white", antialias = c("default", "none", "gray", "subpixel"), symbolfamily) cairo_pdf(filename = if(onefile) "Rplots.pdf" else "Rplot%03d.pdf", width = 7, height = 7, pointsize = 12, onefile = FALSE, family = "sans", bg = "white", antialias = c("default", "none", "gray", "subpixel"), fallback_resolution = 300, symbolfamily) cairo_ps(filename = if(onefile) "Rplots.ps" else "Rplot%03d.ps", width = 7, height = 7, pointsize = 12, onefile = FALSE, family = "sans", bg = "white", antialias = c("default", "none", "gray", "subpixel"), fallback_resolution = 300, symbolfamily)
the name of the output file.
The page number is substituted if a C integer format is included in
the character string, as in the default. (The result must be less
the width of the device in inches.
the height of the device in inches.
the default pointsize of plotted text (in big points).
should all plots appear in one file or in separate files?
one of the device-independent font families,
On unix-alikes (incl.\ Mac), see
the ‘Cairo fonts’ section in the help for
the initial background colour: can be overridden by setting par("bg").
string, the type of anti-aliasing (if any) to be used;
numeric: the resolution in dpi used when falling back to bitmap output. Prior to R 3.3.0 this depended on the cairo implementation but was commonly 300.
a length-one character string that specifies the font family to be used as the "symbol" font (e.g., for plotmath output).
SVG (Scalar Vector Graphics) is a W3C standard for vector graphics.
See https://www.w3.org/Graphics/SVG/. The output from
is SVG version 1.1 for
onefile = FALSE (the default), otherwise
SVG 1.2. (Few SVG viewers are capable of displaying multi-page SVG
Note that unlike
cairo_ps sometimes record bitmaps
and not vector graphics. On the other hand, they can
(on suitable platforms) include a much wider range of UTF-8 glyphs,
and embed the fonts used.
The output produced by
cairo_ps(onefile = FALSE) will be
encapsulated postscript on a platform with cairo >= 1.6.
R can be compiled without support for any of these devices: this will be reported if you attempt to use them on a system where they are not supported. They all require cairo version 1.2 or later.
If you plot more than one page on one of these devices and do not
include something like
%d for the sequence number in
file (or set
onefile = TRUE) the file will contain the
last page plotted.
There is full support of semi-transparency, but using this is one of
the things liable to trigger bitmap output (and will always do so for
A plot device is opened: nothing is returned to the R interpreter.
Anti-aliasing is applied to both graphics and fonts. It is generally
preferable for lines and text, but can lead to undesirable effects for
fills, e.g. for
image plots, and so is never used for
antialias = "default" is in principle platform-dependent, but
seems most often equivalent to
antialias = "gray".
This section describes the implementation of the conventions for graphics devices set out in the ‘R Internals’ manual.
The default device size is in pixels (
svg) or inches.
Font sizes are in big points.
The default font family is Helvetica.
Line widths are multiples of 1/96 inch.
Circle radii have a minimum of 1/72 inch.
Colours are interpreted by the viewing application.
Support for all these devices are optional, so in packages they should
be used conditionally after checking
In principle these devices are independent of X11 (as is seen by their
presence on Windows). But on a Unix-alike the cairo libraries may be
distributed as part of the X11 system and hence that (for example, on
x86_64 macOS, XQuartz) may need to be installed.
capabilities to see if cairo is supported.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.