write_svg: Writes SVG to file

Description Usage Arguments Details Examples

View source: R/svgtools.R

Description

Writes SVG to file

Usage

1
write_svg(svg, file, remove_hidden = TRUE, flatten = FALSE)

Arguments

svg

XML document with SVG content.

file

Path to file or connection to write to (see write_xml).

remove_hidden

Should hidden elements (with XML attribute display="none") be removed? (default TRUE)

flatten

Should grouping of SVG elements be removed? (default FALSE)

Details

Both remove_hidden=TRUE and flatten=TRUE do not alter the XML document object itself. Therefore, subsequent calls to stackedBar and other functions remain possible.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#read SVG file
fpath <- system.file("extdata", "fig3.svg", package="svgtools")
svg <- read_svg(file = fpath)

#adjust some elements of SVG
svg <- stackedBar(svg = svg, frame_name = "frame", group_name = "overall", 
                  scale_real = c(0,160), values = c(10,42,106), 
                  alignment = "vertical")

## Not run: 
#write SVG file to disk and remove all groupings
write_svg(svg = svg, file = "myChart.svg", flatten = TRUE)

## End(Not run)

svgtools documentation built on Dec. 14, 2021, 5:10 p.m.