--- title: "Why hrbrthemes?" author: "Bob Rudis" date: "`r Sys.Date()`" output: rmarkdown::html_vignette: toc: true vignette: > %\VignetteIndexEntry{Why hrbrthemes?} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- The `hrbrthemes` package has two goals. First, it provides a base theme that focuses on typographic elements, including where various labels are placed as well as the fonts that are used. The second goal centers around productivity for a production workflow. In fact, this "production workflow" is the context for where the elements of `hrbrthemes` should be used. A "production workflow" is when you intend for the output of your work to be put into a publication of some kind, whether it be a blog post, academic paper, presentation, internal report or industry publication. When you're cranking through an analysis, the visual elements don't need to be perfect. They are there to validate/support your work and are more of a starting point for the finished product than anything else. The level of attention to detail on the final graphical products can be a great motivator for your audience to either dive deep into your analysis text or relegate it to the TLDR pile. ## Font Fundamentals There are nigh countless tomes written about the colors you should consider using in charts as well as how to produce "minimal" charts (i.e. eliminate "chart junk"). One area that is rarely discussed is the use of fonts in charts (i.e. chart typography). The `hrbrthemes` package is _very opinionated_ about chart typography: - The font family used should be **sans-serif** typeface - The font family used should have an awesome, default **kern[ing] table** - The font family used should have **tabular figures** (digits) vs _proportional_ ones - The font family used should be a **condensed** or **narrow** typeface - Ideally, the font family used will have 100, 300, 500, 700 and 900 weights vs regular, bold, italic and bold italic - Because we're working in `ggplot2`-land, the font family used should also be a TrueType font (TTF) ### Why **sans-serif**? To use a gross oversimplification, there are two basic font types: Serif and Sans-serif (that's a lie of convenience, there are more than two). `hrbrthemes` suggests using sans-serif fonts since they have a more "modern" feel to them, you're not producing long-form text and labels on charts may need to scale down to small sizes. Typography nerds on either side of the serif vs sans-serif debate can point to 100+ years of research-based evidence supporting their particular "side". You can compare the typography in the two (non-`hrbrthemes`) charts below to see if you prefer sans-serif over serif: ```{r echo=FALSE, fig.width=8} library(ggplot2) library(gridExtra) ggplot(mtcars, aes(wt, mpg)) + geom_point() + labs(x="Weight (tons)", y="Efficiency (MPG)", title="Lorem ipsum dolor sit amet", subtitle="Mauris ultricies sem volutpat magna venenatis") -> gg grid.arrange( gg + theme_minimal(base_family="serif") + theme(plot.margin=margin(t=20, b=20, l=15, r=30)), gg + theme_minimal(base_family="sans") + theme(plot.margin=margin(t=20, b=20, l=30, r=15)), ncol=2 ) ``` If you work in a company, your communications department likely has a set of core brand fonts and said font groups likely contain both serif and sans-serif and you should strive to keep with the brand image and use whatever font(s) work best or work with your comms team to pick a standard, complementary font for the charts you produce. ### Kern-what? [Kerning](https://en.wikipedia.org/wiki/Kerning) is nothing more than a fancy word for spaces between letters and fonts have built-in tables for how various pairs of letters should be placed next to each other. Great fonts have kerning tables that typography nerds immediately recognize and adore. Fonts with poor kerning tables are easily recognized as such by even the least font-aware viewer.