November 3, 2018

ewenthemes (AKA how to mod hrbrthemes)

This post is a short one, (partly) accompanying the last one on typography for blogodown.

If you use ggplot2, you might want to make sure your site’s typeface(s) are mirrored in your featured plotting handy-work. You could also take this opportunity to develop some custom ggplot2 theme flourishes, helping your plots and posts make a charming fit.

Bob Rudis (AKA hrbrmstr) made perhaps the seminal ggplot2 themes package so far, hrbrthemes. Bob nicely explains the opinions that form “what’s in the box”, chiefly a desire for good typography and minimal chart junk. It’s really nice.

So, I made my own twist of a classic - introducing ewenthemes. I plan to use/maintain the package to create charts that sit pretty within posts on the site, by adopting similar design decisions.

Following Bob’s lead, I chose to ship Work Sans inside the software and include functions to install it on your system with help from extrafont. Font handling is surprisingly tricksy in R and this seems to be the best option right now.

The current core themes, theme_ewen (Arial Narrow-based) and theme_ewen_ws (Work Sans-based) draw heavily from hrbrthemestheme_ipsum with some modifications - the chart grid runs on major horizontal lines only, and a thick x-axis line is used by default. Some text properties, notably size and colour, are also modified for readability on mobile devices. Take a look at the commit history of ewenthemes to see, in detail, what changed from the original package.