r-lib / svglite

A lightweight svg graphics device for R
https://svglite.r-lib.org
180 stars 39 forks source link

Support multiple pages #84

Closed jeroen closed 4 years ago

jeroen commented 7 years ago

Is there some way we can make svglite() or svgstring() or a wrapper support multiple pages? The png() device supports sprintf syntax to denote the page number in the filename:

svglite::svglite("Rplot%03d.svg")
ggplot2::qplot(iris$Species)
ggplot2::qplot(iris$Sepal.Length)
dev.off()

Also useful would be if svgstring() returns a character vector of length > 1 for multiple pages:

s <- svgstring()
ggplot2::qplot(iris$Species)
ggplot2::qplot(iris$Sepal.Length)
dev.off()
svgdata <- s()
length(svgdata)

This would allow us to use svglite with evaluate/knitr. Currently this fails:

options(device = svglite::svglite)
out <- evaluate::evaluate('ggplot2::qplot(iris$Species); ggplot2::qplot(iris$Sepal.Length)')