Opinionated, typographic-centric ggplot2 themes and theme components
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

197 lines
14 KiB

<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Why hrbrthemes? • hrbrthemes</title>
<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script><!-- Bootstrap --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha256-916EbMg70RQy9LHiGkXzG8hSg9EdNy97GazNG/aiY1w=" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous">
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script><!-- sticky kit --><script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script><meta property="og:title" content="Why hrbrthemes?">
<meta property="og:description" content="">
<meta name="twitter:card" content="summary">
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container template-article">
<header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">hrbrthemes</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.0</span>
</span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="../index.html">
<span class="fa fa-home fa-lg"></span>
</a>
</li>
<li>
<a href="../reference/index.html">Reference</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Articles
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/why_hrbrthemes.html">Why hrbrthemes?</a>
</li>
</ul>
</li>
<li>
<a href="../news/index.html">Changelog</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/hrbrmstr/hrbrthemes">
<span class="fa fa-github fa-lg"></span>
</a>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
<!--/.container -->
</div>
<!--/.navbar -->
</header><div class="row">
<div class="col-md-9 contents">
<div class="page-header toc-ignore">
<h1>Why hrbrthemes?</h1>
<h4 class="author">Bob Rudis</h4>
<h4 class="date">2019-02-07</h4>
<small class="dont-index">Source: <a href="https://github.com/hrbrmstr/hrbrthemes/blob/master/vignettes/why_hrbrthemes.Rmd"><code>vignettes/why_hrbrthemes.Rmd</code></a></small>
<div class="hidden name"><code>why_hrbrthemes.Rmd</code></div>
</div>
<p>The <code>hrbrthemes</code> 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 <code>hrbrthemes</code> should be used.</p>
<p>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.</p>
<div id="font-fundamentals" class="section level2">
<h2 class="hasAnchor">
<a href="#font-fundamentals" class="anchor"></a>Font Fundamentals</h2>
<p>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 <code>hrbrthemes</code> package is <em>very opinionated</em> about chart typography:</p>
<ul>
<li>The font family used should be <strong>sans-serif</strong> typeface</li>
<li>The font family used should have an awesome, default <strong>kern[ing] table</strong>
</li>
<li>The font family used should have <strong>tabular figures</strong> (digits) vs <em>proportional</em> ones</li>
<li>The font family used should be a <strong>condensed</strong> or <strong>narrow</strong> typeface</li>
<li>Ideally, the font family used will have 100, 300, 500, 700 and 900 weights vs regular, bold, italic and bold italic</li>
<li>Because we’re working in <code>ggplot2</code>-land, the font family used should also be a TrueType font (TTF)</li>
</ul>
<div id="why-sans-serif" class="section level3">
<h3 class="hasAnchor">
<a href="#why-sans-serif" class="anchor"></a>Why <strong>sans-serif</strong>?</h3>
<p>To use a gross oversimplification, there are two basic font types: <span style="font-family:serif">Serif</span> and <span style="font-family:sans-serif">Sans-serif</span> (that’s a lie of convenience, there are more than two). <code>hrbrthemes</code> 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”.</p>
<p>You can compare the typography in the two (non-<code>hrbrthemes</code>) charts below to see if you prefer sans-serif over serif:</p>
<p><img src="why_hrbrthemes_files/figure-html/unnamed-chunk-1-1.png" width="768"></p>
<p>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.</p>
</div>
<div id="kern-what" class="section level3">
<h3 class="hasAnchor">
<a href="#kern-what" class="anchor"></a>Kern-what?</h3>
<p><a href="https://en.wikipedia.org/wiki/Kerning">Kerning</a> 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.</p>
<center>
<p><a href="https://www.xkcd.com/1015/"><img src="kerning.png"></a><br><a href="https://www.xkcd.com/1015/" class="uri">https://www.xkcd.com/1015/</a></p>
</center>
<p>Bad kerning will be a distraction from the chart contents. Great kerning will be a subconscious reinforcement of just how awesome your visualizations are.</p>
</div>
<div id="tabula-figura" class="section level3">
<h3 class="hasAnchor">
<a href="#tabula-figura" class="anchor"></a>Tabula Figura</h3>
<p>Tabular digits line up when placed on top of each other. Proportional ones do not. This is best explained visually:</p>
<center>
<p><img src="numbers.png"></p>
</center>
<p>Can you spot the proportional digits from the tabular ones? (Hint: there are two of each.)</p>
<p>Proportional digits stand out (in a “yes, I just spilled sriracha on my white shirt” way) when used on the Y axis of a chart and the numeric labels contain numbers of varying widths (like Hind and Encode Sans Condensed in the example above). Using proportional digits will be one further, subtle, subliminal message to viewers that there is something not-quite-awesome about your creation.</p>
</div>
<div id="clean-and-compact" class="section level3">
<h3 class="hasAnchor">
<a href="#clean-and-compact" class="anchor"></a>Clean and compact</h3>
<p>The figure used in the previous section provided an example of condensed/narrow fonts and regular. Chart space is at a premium and it’s important to label and annotate your creations (sparingly but sufficiently). Choosing a font that is too wide will reduce your available space and also make it harder to read the text. Choosing a font that is too narrow/compressed/condensed will create different legiibility problems.</p>
<p>NOTE: It’s <em>really</em> hard to find a <strong>free</strong> condensed/narrow font with great kerning pairs and tabular digits. Such is the way of things.</p>
<p>(As an aside, the default line-height for Hind and M+ 1c is also sub-optimal and would require tweaking in <code>ggplot2</code> calls to correct.)</p>
</div>
<div id="weight--what" class="section level3">
<h3 class="hasAnchor">
<a href="#weight--what" class="anchor"></a>Weight. What?</h3>
<p>Most fonts (and, more importantly, most <em>free</em> fonts) come in regular, <em>italic</em>, <strong>bold</strong> and bold italic (which I can’t bring myself to code in here). You really want to avoid italic and bold italic, especially at very small or very large sizes. Bold should be used sparingly as it draws the eye to that text.</p>
<p>Ideally, you’d use a font with a broad diversity of <em>weights</em>. The term <em>weight</em> can be though of as a numeric scale (the one used here was introduced by TrueType) between 100 and 900 (usually at 100 or 200 increments) or with names ranging from “hairline” through “ultra-black”.</p>
<p>Take Open Sans, for example:</p>
<center>
<p><img src="weights.png"></p>
</center>
<p>There is plenty of room to work with in Open Sans. You can embolden the title, but mute the other labels and choose appropriate label fonts to both enhance style as well as reduce importance. Lighter weights are great for captions and even some direct annotations. Heaver weights should be used sparingly and for emphasis.</p>
</div>
<div id="ttf--meh-" class="section level3">
<h3 class="hasAnchor">
<a href="#ttf--meh-" class="anchor"></a>TTF. Meh.</h3>
<p>I’ll use another over-simplification and state that there two main font types: OTF and TTF (it’s another lie of convenience). OTF (OpenType) is more modern and flexible. TTF (TrueType) has been around longer and was a precursor to OTF. If you make PDFs or PostScript files from R you pretty much <em>need</em> to use TTF fonts due to the underlying tooling that it relies on. If you are making PNGs or SVGs you can likely use OTF but most communciations teams and publications want PDFs.</p>
</div>
</div>
<div id="spacing-out" class="section level2">
<h2 class="hasAnchor">
<a href="#spacing-out" class="anchor"></a>Spacing Out</h2>
<p>Label/title placement is also important, as is the distance between those elements. Put text bits too close to each other or too far apart from each other will send negative subliminal messages. Centering vs left- or right-justification will also convey other messages (old-school vs modern, to put it somewhat bluntly).</p>
<p><code>hrbrthemes</code> makes opinionated choices over the spacing between title elements and all labels. For some elements, it makes very new choices (such as the justification of the axis labels).</p>
<p>The font choices you make may cause you to adjust the <code>hrbrthemes</code> defaults, especially if you choose a font with a wonky line-height.</p>
</div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<div id="tocnav">
<h2 class="hasAnchor">
<a href="#tocnav" class="anchor"></a>Contents</h2>
<ul class="nav nav-pills nav-stacked">
<li><a href="#font-fundamentals">Font Fundamentals</a></li>
<li><a href="#spacing-out">Spacing Out</a></li>
</ul>
</div>
</div>
</div>
<footer><div class="copyright">
<p>Developed by Bob Rudis.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
</div>
</footer>
</div>
</body>
</html>