JPlotToSVG: Plot to an SVG file

View source: R/plot_to_file.R

JPlotToSVGR Documentation

Plot to an SVG file

Description

Writes the output of a plot to a SVG file. If you are using ggplot, try either using JPlotToSVG(filename, print(<plotting code>)) or else ggsave().

Usage

JPlotToSVG(
  filename,
  plotExpr,
  width = 180,
  height = NA,
  aspectRatio = 3/2,
  units = c("mm", "cm", "in"),
  bg = "white",
  family = "Helvetica",
  onlyIfDoesntExist = FALSE,
  createDirectory = TRUE,
  ...
)

Arguments

filename

The name of the SVG file to create or overwrite. If NULL, plot output goes to the current device.

plotExpr

A function or expression which will produce the plot to be written to the file.

width

The width of the output SVG file in units.

height

The height of the output SVG file in units. Defaults to width / aspectRatio. If height is specified, aspectRatio will be ignored.

aspectRatio

Aspect ratio (width / height) of the output EPS file.

units

Units of width and height.

bg

Background colour - may be "transparent" for no background.

family

The font family to be used. Passed to svg.

onlyIfDoesntExist

If TRUE and the output file already exists, JPlotToEPS will do nothing.

createDirectory

If TRUE and filename is located in a directory which doesn't exist, the directory will be created.

...

Any additional arguments are passed to svg. These may be used to control text size (pointsize), font family (family) and so on.

Value

The result of evaluating plotExpr is returned invisibly (which means it is not automatically printed).

See Also

cairo

Examples

## Not run: 
plotWithAlpha <- function() {
    plot(1:3, type = 'l', lwd = 20, col = "#ffcc8888")
    lines(3:1, lwd = 20, col = "#88ccff88")
}

JPlotToSVG(filename, plotWithAlpha)

## End(Not run)


JimMcL/JUtils documentation built on Nov. 7, 2024, 11:25 a.m.