How to share your plots better on the web

[This article was first published on Quantitative Doodles, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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 their blog: Quantitative Doodles.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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)