Paul Murrell
The University of Auckland
December 2017
SVG is just another graphics format, like PDF or PNG, but it is the best format for graphics in a web page.
svg()
from 'graphics'
devSVG()
from 'RSvgDevice'
CairoSVG()
from 'Cairo'
svgPlot()
from 'SVGAnnotation'
svglite()
from 'svglite'
grid.export()
from 'gridSVG'
#1. Fancy SVG features.
grid.circle(x=.3, r=.4, name="circle")
colors <- rev(sequential_hcl(5))
radial <- radialGradient(colors)
grid.gradientFill("circle", radial)
grid.export()
#1. Fancy SVG features.
#2. Labelled and Structured SVG.
grid.circle(x=.3, r=.4, name="circle")
grid.export()
<g id="circle.1">
<circle id="circle.1.1" cx="129.6" cy="108" r="86.4"/>
</g>
#2. Labelled and Structured SVG.
svg()
grid.circle(x=.3, r=.4, name="circle")
dev.off()
<path d="M 352.800781 252 C 352.800781 363.339844 262.539062
453.601562 151.199219 453.601562 C 39.859375
453.601562 -50.398438 363.339844 -50.398438 252
C -50.398438 140.660156 39.859375 50.398438
151.199219 50.398438 C 262.539062 50.398438
352.800781 140.660156 352.800781 252 "/>
#1. 'grid' graphics only.
#1. 'grid' graphics only.
perspPlot()
grid.export()
→
#2. 'gridSVG' is SLOW.
#3. No-one cares about fancy SVG features
☹
#4. No-one cares about labelling and structure
☹
'gridSVG' is a PAINFULLY SLOW and INCOMPLETE solution for problems that DO NOT EXIST.
#1. The 'gridGraphics' package
#1. The 'gridGraphics' package
perspPlot()
grid.echo()
grid.export()
→
#2. Speeding up 'gridSVG'
#2. Speeding up 'gridSVG'
library(profvis)
p <- profvis({
grid.export("old.svg")
}, interval=.1)
Click the code to see the profiling output.
#2. Speeding up 'gridSVG'
library(profvis)
p <- profvis({
grid.export("new.svg")
}, interval=.1)
Click the code to see the profiling output.
#2. Speeding up 'gridSVG'
#3. The 'BrailleR' package
library(BrailleR)
h <- hist(rnorm(10))
MakeAccessibleSVG(h)
Click the code to see the accessible plot.
persp()
plots as
'grid' plots in 'gridGraphics' is thanks to the
work of Jason Wen.
MakeAccessibleSVG()
.