Interactive, Illustrator-quality graphics with R

August 5, 2016
By

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

While many media properties including the New York Times, FiveThirtyEight and FlowingData use the R language to prepare graphics for publication, they often use Adobe Illustrator or similar graphics tools to touch up the last 5% or so of the graphics. Not so for Switzerland's news site swissinfo.ch, whose data journalist Duc-Quang Nguyen created these gorgeous bar charts showing the representation of major countries in various categories of Olympic events in Rio:

Olympics

Note the use of an attractive colour pallette, style-compatible fonts, and even the official Olympic icons for the sports. I just took a screenshot here, but if you click through to the actual site you'll notice that these graphics are also scale-independent (you can zoom in on your browser and they'll look better, not worse) and even interactive (pop-ups appear with country-specific data when you hover over a bar).

Duc-Quang has been generous enough to provide the R code behind these charts if you'd like to try your hand at something similar. The data themselves were scraped from the official Rio 2016 site. The bar charts were created using a standard geom_bar plot using ggplot2, with a custom theme to set the font to OpenSans Condensed. The interactive elements were added using the ggiraph package and the geom_bar_interactive function. The chart titles (including the icons) were created as HTML headers directly, which was then exported along with the interactive charts using the save_html function.

Seriously, go back and take a look at all of the charts in their interactive glory by following the link below. Now that's how to elevate a simple bar chart into something gorgeous.

SWI swissinfo.ch: Swiss Olympians – the solo specialists

To leave a comment for the author, please follow the link and comment on their blog: Revolutions.

R-bloggers.com 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.

Sponsors

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)