Skip to contents

This function produces SVG files (compliant to the current w3 svg XML standard) where elements can be made interactive.

In order to generate the output, used fonts must be available on the computer used to create the svg, used fonts must also be available on the computer used to render the svg.


  file = "Rplots.svg",
  width = 6,
  height = 6,
  bg = "white",
  pointsize = 12,
  standalone = TRUE,
  setdims = TRUE,
  canvas_id = "svg_1",
  title = NULL,
  desc = NULL,
  fonts = list()



the file where output will appear.

height, width

Height and width in inches.


Default background color for the plot (defaults to "white").


default point size.


Produce a stand alone svg file? If FALSE, omits xml header and default namespace.


If TRUE (the default), the svg node will have attributes width & height set.


svg id within HTML page.


A label for accessibility purposes (aria-label/aria-labelledby). Be aware that when using this, the browser will use it as a tooltip for the whole svg and it may class with the interactive elements' tooltip.


A longer description for accessibility purposes (aria-description/aria-describedby).


Named list of font names to be aliased with fonts installed on your system. If unspecified, the R default families "sans", "serif", "mono" and "symbol" are aliased to the family returned by match_family().

If fonts are available, the default mapping will use these values:

R familyFont on WindowsFont on UnixFont on Mac OS
sansArialDejaVu SansHelvetica
serifTimes New RomanDejaVu serifTimes
monoCourierDejaVu monoCourier
symbolSymbolDejaVu SansSymbol

As an example, using fonts = list(sans = "Roboto") would make the default font "Roboto" as many ggplot theme are using theme_minimal(base_family="") or theme_minimal(base_family="sans").

You can also use theme_minimal(base_family="Roboto").

See also


fileout <- tempfile(fileext = ".svg")
dsvg(file = fileout)
plot(rnorm(10), main="Simple Example", xlab = "", ylab = "")
#> agg_png 
#>       2