How to share your plots better on the web

June 24, 2011
By

(This article was first published on Quantitative Doodles, and kindly contributed to R-bloggers)

R bloggers (including me) typically post plots online as portable network graphics (PNG). This is silly because plots generally work better as vector graphics. For years I’ve wanted to host scalable vector graphics (SVG) online, but none of the image hosting sites support them.

In case you don’t know, SVGs are awesome.

  • The are vector graphics, so they’re small and resolution isn’t an issue.
  • They support animation.
  • You can edit them in Inkscape.
  • You can edit them in a text editor.
  • You can parse them with an XML parser.
  • You can edit them really easily with scripts.
  • And web browsers support them.

Considering how outrageously tiny they are, it’s silly that something like imageshack doesn’t exist for SVG.

So I made one: http://svg.thomaslevine.com
Code is here.

Since vector graphics are reasonably small, I’m happy to host them, but you can also host them on your own server of course.

Now for a demonstration (and a preview of my next blog post).

So you plot your plot with the svg device.

> svg(‘r_tweets.svg’,width=9,height=6)
> plot_searches(subjects,tweet_text.R,ignore.case=T,main=’What are people tweeting about? (case-insensitive)’)
> dev.off()

Then you upload it. Then you copy the embed code into your blog post. Voilà.

r_tweets.svg

And then you continue writing your blog post as if this were any other image.

The end.

To leave a comment for the author, please follow the link and comment on his blog: Quantitative Doodles.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.