Skip to content
 

Web-friendly visualizations in R

Aleks points me to this new tool from Wojciech Gryc. Right now I save my graphs as pdfs or pngs and then upload them to put them on the web. I expect I’ll still be doing this for awhile—I like having full control of what my graphs look like—but Gryc’s default plots might be useful for lots of people making their analyses more accessible.

Here’s an example:

x = rnorm(30)
y = rnorm(30)
wv.plot(x, y, "~/Desktop/scatterplot", height=300, width=300, xlim=c(-2.5,2.5), ylim=c(-2.5,2.5), xbreaks=c(0), ybreaks=c(0))

 


5 Comments

  1. mpingo says:

    Thanks for the post… but can you be so kind to give the url of this “new tool” from Wojciech Gryc. I tried googling it but couldn’t find it.

    Thanks again!

  2. Jon Baron says:

    This looks really nice. At first look, though, it is not something you can use for production graphs for papers as well as web graphics, unless you can somehow include SVG. (I don’t think you can do that with LaTeX, for example.)

    An alternative, which I have been using, is simply to use the SVG device in R’s grDevices packages, or RSVGTipsDevice, to output whatever plot you already have in some other format. I have been including them in html with the tag, but it now seems that there are other ways to do it.

    In the old days, all you could do was include them in xml, and they worked only in Firefox, like this one http://www.sas.upenn.edu/~baron/900/bayes.xml, which illustrates Bayes’ theorem.

  3. Jon Baron says:

    It was supposed to say “with the object tag” but that got suppressed.

  4. Rick Wicklin says:

    Bear in mind that SVG is not supported by all browsers. For example, SVG is not supported in Internet Explorer 8. Furthermore, this image looks horrible in Internet Explorer 9 (the axes and reference lines are missing completely!) although supposedly IE9 supports “basic SVG.”

    Consequently, you might not want to start using SVG yet.