How to share your plots better on the web

June 24, 2011

(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: 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,,main=’What are people tweeting about? (case-insensitive)’)

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


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 their blog: Quantitative Doodles. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, 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.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)