svglite (version 1.2.3.2)

svglite: An SVG Graphics Driver

Description

This function produces graphics compliant to the current w3 svg XML standard. The driver output is currently NOT specifying a DOCTYPE DTD.

Usage

svglite(
  file = "Rplots.svg",
  width = 10,
  height = 8,
  bg = "white",
  pointsize = 12,
  standalone = TRUE,
  system_fonts = list(),
  user_fonts = list()
)

Arguments

file

The file where output will appear.

height, width

Height and width in inches.

bg

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

pointsize

Default point size.

standalone

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

system_fonts

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().

user_fonts

Named list of fonts to be aliased with font files provided by the user rather than fonts properly installed on the system. The aliases can be fonts from the fontquiver package, strings containing a path to a font file, or a list containing name and file elements with name indicating the font alias in the SVG output and file the path to a font file.

Details

svglite provides two ways of controlling fonts: system fonts aliases and user fonts aliases. Supplying a font alias has two effects. First it determines the font-family property of all text anchors in the SVG output. Secondly, the font is used to determine the dimensions of graphical elements and has thus an influence on the overall aspect of the plots. This means that for optimal display, the font must be available on both the computer used to create the svg, and the computer used to render the svg. See the fonts vignette for more information.

References

W3C Scalable Vector Graphics (SVG): http://www.w3.org/Graphics/SVG/Overview.htm8

See Also

pictex, postscript, Devices

Examples

Run this code
# NOT RUN {
# Save to file
svglite(tempfile("Rplots.svg"))
plot(1:11, (-5:5)^2, type = 'b', main = "Simple Example")
dev.off()

# Supply system font aliases. First check the font can be located:
gdtools::match_family("Verdana")

# Then supply a list of aliases:
fonts <- list(sans = "Verdana", mono = "Times New Roman")
svglite(tempfile("Rplots.svg"), system_fonts = fonts)
plot.new()
text(0.5, 0.5, "Some text", family = "mono")
dev.off()

# See the fonts vignettes for more options to deal with fonts

# }

Run the code above in your browser using DataCamp Workspace