The SVGAnnotation Package

Last Release: 0.93-1 (25 Jan 2012)

Paper on the SVGAnnotation package in the Journal of Statistical Software (JSS)
(HTML version Paper that provides the live examples interactively. And a separate version with just the figures without the narrative.)

This package is a proof-of-concept and illustration of how we can post-process the output of R's graphics from cairo's SVG generation. We can read the resulting plots back into R and make the plots interactive and dynamic in simple ways such as

and generally use SVG's rich facilities.

See some examples. These are best viewed using the Opera Web browser. Alternatively, use Firefox but the animations won't work. The stand-alone SVG viewer Batik can also be used.

In addition to rendering R plots, one can use SVG to create quite sophisticated interactive displays. There is an interesting collection of examples that combine SVG and ECMAscript at http://www.carto.net/papers/svg/samples/#jscr. For example,

Additionally, there is a collection of JavaScript and SVG-based widgets.

This is a quite different approach from Tony Plate's RSVGTipDevice (which builds on Jake Luciani's RSvgDevice). Firstly, this uses R's interface to cairo for rendering. However, we could do the same high-level post-processing using RSVGTipDevice or RSvgDevice. But more importantly, we are identifying elements of the plots after R has created them. We do not have to set global variables for specifying tooltip text and then draw rectangles, circles, text, polygons, etc. Instead, we draw the plot as usual, and then we examine the result and enhance it. This means we can use any functionality in R for creating a plot without have to adapt it. The hard part is to identify the elements in the result. But for many common plots, this is not too difficult.

This is part of a book Deb Nolan and I are writing on Web Technologies for statistics and R. We are also working on visualization via

and presenting dynamic interactive results via Open Office XML using Microsoft Office, K Office, Open Office, etc. The mindset is that we as a field have a lot of opportunity to move to richer, more interactive and dynamic visualization methods not just for data analysis, but also presentation of the results.

Heatmaps

Here is a detailed description of an approach to associating elements in SVG and an R plot for the heatmap() function.


Duncan Temple Lang <duncan@wald.ucdavis.edu>
Last modified: Wed Jan 25 15:54:28 PST 2012