svglite v1.2.1

0

Monthly downloads

0th

Percentile

An 'SVG' Graphics Device

A graphics device for R that produces 'Scalable Vector Graphics'. 'svglite' is a fork of the older 'RSvgDevice' package.

Readme

svglite

Build Status Coverage Status CRAN Status Badge

svglite is a graphics device that produces clean svg output, suitable for use on the web, or hand editing. Compared to the built-in svg(), svglite is considerably faster, produces smaller files, and leaves text as is.

Installation

Install the development version from github with:

# install.packages("devtools")
devtools::install_github("hadley/svglite")

Benchmarks

Compared to the base svg device, svglite is quite a bit faster:

library(svglite)
x <- runif(1e3)
y <- runif(1e3)

tmp1 <- tempfile()
tmp2 <- tempfile()
system.time({
  svglite(tmp1)
  plot(x, y)
  dev.off()
})
#>    user  system elapsed 
#>   0.003   0.001   0.003 

system.time({
  svg(tmp2, onefile = TRUE)
  plot(x, y)
  dev.off()
})
#>    user  system elapsed 
#>   0.015   0.001   0.017

It also produces considerably smaller files:

file.size(tmp1) / 1024
#> [1] 93.54785
file.size(tmp2) / 1024
#> [1] 321.1357

In both cases, compressing to make .svgz is worthwhile:

gz <- function(in_path, out_path = tempfile()) {
  out <- gzfile(out_path, "w")
  writeLines(readLines(in_path), out)
  close(out)

  invisible(out_path)
}
file.size(gz(tmp1)) / 1024
#> [1] 9.064453
file.size(gz(tmp2)) / 1024
#> [1] 38.6123

Functions in svglite

Name Description
svgstring Access current SVG as a string.
xmlSVG Run plotting code and return svg
editSVG Run plotting code and open svg in OS/system default svg viewer or editor.
htmlSVG Run plotting code and view svg in RStudio Viewer or web broswer.
stringSVG Run plotting code and return svg as string
svglite An SVG Graphics Driver
No Results!

Vignettes of svglite

Name
fonts.Rmd
scaling.Rmd
No Results!

Last month downloads

Details

Encoding UTF-8
LinkingTo Rcpp, gdtools, BH
License GPL (>= 2)
URL https://github.com/r-lib/svglite
BugReports https://github.com/r-lib/svglite/issues
RoxygenNote 6.0.1
VignetteBuilder knitr
NeedsCompilation yes
Packaged 2017-09-11 18:24:26 UTC; lionel
Repository CRAN
Date/Publication 2017-09-11 20:04:15 UTC

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/svglite)](http://www.rdocumentation.org/packages/svglite)