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:
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
Just a couple notes if you try to run the code:
You will need the dev version of ggplot
I get a is.numeric(width) error with the original code which is corrected by changing
width = "100%" to width = 1 in Line 176
Posted by: Rajesh Sahasrabuddhe | August 08, 2016 at 05:31