• Stars
    star
    1,139
  • Rank 40,911 (Top 0.9 %)
  • Language
    R
  • License
    Other
  • Created almost 8 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🔏 Opinionated, typographic-centric ggplot2 themes and theme components

Project Status: Active – The project has reached a stable, usable state and is being actively developed. Signed by Signed commit %

cran checks CRAN status Minimal R Version License downloads DOI

hrbrthemes

Additional Themes and Theme Components for ‘ggplot2’


This is a very focused package that provides typography-centric themes and theme components for ggplot2.

The core theme: theme_ipsum (“ipsum” is Latin for “precise”) uses Arial Narrow which should be installed on practically any modern system, so it’s “free”-ish. This font is condensed, has solid default kerning pairs and geometric numbers. That’s what I consider the “font trifecta” must-have for charts. An additional quality for fonts for charts is that they have a diversity of weights. Arial Narrow (the one on most systems, anyway) does not have said diversity but this quality is not (IMO) a “must have”.

The following functions are implemented/objects are exported:

Themes:

  • theme_ipsum: Arial Narrow
  • theme_ipsum_gs: Goldman Sans Condensed
  • theme_ipsum_es: Econ Sans Condensed
  • theme_ipsum_rc: Roboto Condensed
  • theme_ipsum_ps: IBM Plex Sans font
  • theme_ipsum_pub: Public Sans
  • theme_ipsum_tw: Titilium Web
  • theme_modern_rc: Roboto Condensed dark theme
  • theme_ft_rc: Dark theme based on FT’s dark theme (Roboto Condensed)

Scales (that align with various themes):

  • scale_color_ipsum: Discrete color & fill scales based on the ipsum palette
  • scale_colour_ipsum: Discrete color & fill scales based on the ipsum palette
  • scale_fill_ipsum: Discrete color & fill scales based on the ipsum palette
  • scale_color_ft: Discrete color & fill scales based on the FT palette
  • scale_colour_ft: Discrete color & fill scales based on the FT palette
  • scale_fill_ft: Discrete color & fill scales based on the FT palette
  • scale_x_comma: X & Y scales with opinionated presets for percent & comma label formats
  • scale_x_percent: X & Y scales with opinionated presets for percent & comma label formats
  • scale_y_comma: X & Y scales with opinionated presets for percent & comma label formats
  • scale_y_percent: X & Y scales with opinionated presets for percent & comma label formats

Palettes/Named Colors:

  • ipsum_pal: A muted, qualitative color palette
  • ft_cols: FT color palette
  • ft_pal: A bright qualitative color palette
  • ft_text_col: FT color palette

Fonts:

  • font_an: Arial Narrow font name R variable aliases
  • font_es: Econ Sans font name R variable aliases
  • font_es_bold: Econ Sans font name R variable aliases
  • font_es_light: Econ Sans font name R variable aliases
  • font_rc: Roboto Condensed font name R variable aliases
  • font_rc_light: Roboto Condensed font name R variable aliases
  • font_pub: Public Sans font name R variable aliases
  • font_pub_bold: Public Sans font name R variable aliases
  • font_pub_light: Public Sans font name R variable aliases
  • font_pub_thin: Public Sans font name R variable aliases
  • font_ps: PlexSans font name R variable aliases
  • font_ps_light: PlexSans font name R variable aliases

Utilities:

  • flush_ticks: Makes axis text labels flush on the ends
  • ft_geom_defaults: Change geom defaults from black to custom lights for the FT theme
  • gg_check: Spell check ggplot2 plot labels
  • import_econ_sans: Import Econ Sans Condensed font for use in charts
  • import_plex_sans: Import IBM Plex Sans font for use in charts
  • import_roboto_condensed: Import Roboto Condensed font for use in charts
  • modern_geom_defaults: Change geom defaults from black to white for the modern theme
  • update_geom_font_defaults: Update matching font defaults for text geoms

Installation

install.packages("hrbrthemes") # NOTE: CRAN version is 0.8.0
# or
remotes::install_gitlab("hrbrmstr/hrbrthemes")

NOTE: To use the ‘remotes’ install options you will need to have the {remotes} package installed.

Usage

library(hrbrthemes)
library(gcookbook)
library(tidyverse)

# current version
packageVersion("hrbrthemes")
## [1] '0.8.7'

Base theme (Arial Narrow)

ggplot(mtcars, aes(mpg, wt)) +
  geom_point() +
  labs(x="Fuel efficiency (mpg)", y="Weight (tons)",
       title="Seminal ggplot2 scatterplot example",
       subtitle="A plot that is only useful for demonstration purposes",
       caption="Brought to you by the letter 'g'") + 
  theme_ipsum()

Roboto Condensed

ggplot(mtcars, aes(mpg, wt)) +
  geom_point() +
  labs(x="Fuel efficiency (mpg)", y="Weight (tons)",
       title="Seminal ggplot2 scatterplot example",
       subtitle="A plot that is only useful for demonstration purposes",
       caption="Brought to you by the letter 'g'") + 
  theme_ipsum_rc()

New FT Theme!

ggplot(mtcars, aes(mpg, wt)) +
  geom_point(color = ft_cols$yellow) +
  labs(x="Fuel efficiency (mpg)", y="Weight (tons)",
       title="Seminal ggplot2 scatterplot example",
       subtitle="A plot that is only useful for demonstration purposes",
       caption="Brought to you by the letter 'g'") + 
  theme_ft_rc()

IBM Plex Sans

ggplot(mpg, aes(displ, hwy)) +
  geom_jitter(aes(color=class, fill=class), size=3, shape=21, alpha=1/2) +
  scale_x_continuous(expand=c(0,0), limits=c(1, 8), breaks=1:8) +
  scale_y_continuous(expand=c(0,0), limits=c(10, 50)) +
  scale_color_ipsum() +
  scale_fill_ipsum() +
  facet_wrap(~class, scales="free") +
  labs(
    title="IBM Plex Sans Test",
    subtitle="This is a subtitle to see the how it looks in IBM Plex Sans",
    caption="Source: hrbrthemes & IBM"
  ) +
  theme_ipsum_ps(grid="XY", axis="xy") +
  theme(legend.position="none") -> gg

flush_ticks(gg)
## theme(axis.text.x=element_text(hjust=c(0, rep(0.5, 6), 1))) +
## theme(axis.text.y=element_text(vjust=c(0, rep(0.5, 3), 1)))

Scales (Color/Fill)

ggplot(mtcars, aes(mpg, wt)) +
  geom_point(aes(color=factor(carb))) +
  labs(x="Fuel efficiency (mpg)", y="Weight (tons)",
       title="Seminal ggplot2 scatterplot example",
       subtitle="A plot that is only useful for demonstration purposes",
       caption="Brought to you by the letter 'g'") + 
  scale_color_ipsum() +
  theme_ipsum_rc()

Scales (Axis)

count(mpg, class) %>% 
  mutate(pct=n/sum(n)) %>% 
  ggplot(aes(class, pct)) +
  geom_col() +
  scale_y_percent() +
  labs(x="Fuel efficiency (mpg)", y="Weight (tons)",
       title="Seminal ggplot2 column chart example with percents",
       subtitle="A plot that is only useful for demonstration purposes",
       caption="Brought to you by the letter 'g'") + 
  theme_ipsum(grid="Y")

ggplot(uspopage, aes(x=Year, y=Thousands, fill=AgeGroup)) + 
  geom_area() +
  scale_fill_ipsum() +
  scale_x_continuous(expand=c(0,0)) +
  scale_y_comma() +
  labs(title="Age distribution of population in the U.S., 1900-2002",
       subtitle="Example data from the R Graphics Cookbook",
       caption="Source: R Graphics Cookbook") +
  theme_ipsum_rc(grid="XY") +
  theme(axis.text.x=element_text(hjust=c(0, 0.5, 0.5, 0.5, 1))) +
  theme(legend.position="bottom")

update_geom_font_defaults(font_rc_light)

count(mpg, class) %>% 
  mutate(n=n*2000) %>% 
  arrange(n) %>% 
  mutate(class=factor(class, levels=class)) %>% 
  ggplot(aes(class, n)) +
  geom_col() +
  geom_text(aes(label=scales::comma(n)), hjust=0, nudge_y=2000) +
  scale_y_comma(limits=c(0,150000)) +
  coord_flip() +
  labs(x="Fuel efficiency (mpg)", y="Weight (tons)",
       title="Seminal ggplot2 column chart example with commas",
       subtitle="A plot that is only useful for demonstration purposes, esp since you'd never\nreally want direct labels and axis labels",
       caption="Brought to you by the letter 'g'") + 
  theme_ipsum_rc(grid="X")

Spellcheck ggplot2 labels

df <- data.frame(x=c(20, 25, 30), y=c(4, 4, 4), txt=c("One", "Two", "Three"))

ggplot(mtcars, aes(mpg, wt)) +
  geom_point() +
  labs(x="This is some txt", y="This is more text",
       title="Thisy is a titlle",
       subtitle="This is a subtitley",
       caption="This is a captien") +
  theme_ipsum_rc(grid="XY") -> gg

gg_check(gg)
## Possible misspelled words in [title]: (Thisy, titlle)
## Possible misspelled words in [subtitle]: (subtitley)
## Possible misspelled words in [caption]: (captien)

hrbrthemes Metrics

Lang # Files (%) LoC (%) Blank lines (%) # Lines (%)
R 21 0.40 1548 0.41 290 0.5 915 0.5
SVG 4 0.08 310 0.08 0 0.0 0 0.0
JSON 1 0.02 15 0.00 0 0.0 0 0.0
SUM 26 0.50 1873 0.50 290 0.5 915 0.5

{cloc} 📦 metrics for hrbrthemes

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

More Repositories

1

pewpew

⭐ ⭐ ⭐ Build your own IP Attack Maps with SOUND!
JavaScript
1,011
star
2

waffle

🍁 Make waffle (square pie) charts in R
R
747
star
3

ggalt

🌎 Extra Coordinate Systems, Geoms, Statistical Transformations & Scales for 'ggplot2'
R
641
star
4

markdowntemplates

✅🔻 A collection of alternate R markdown templates
CSS
318
star
5

docxtractr

✂️ Extract Tables from Microsoft Word Documents with R
R
169
star
6

vegalite

R ggplot2 "bindings" for Vega-Lite
JavaScript
158
star
7

ggchicklet

🀫 Create Chicklet (Rounded Segmented Column) Charts
HTML
157
star
8

streamgraph

〰️ htmlwidget for creating streamgraph visualizations in R
HTML
146
star
9

metricsgraphics

📈 htmlwidget interface to the MetricsGraphics.js D3 chart library
HTML
133
star
10

sergeant

💂‍♂️ Tools to Transform and Query Data with 'Apache' 'Drill'
R
126
star
11

statebins

Alternative to choropleths of US States ala http://bit.ly/statebins
R
120
star
12

splashr

💦 Tools to Work with the 'Splash' JavaScript Rendering Service in R
R
99
star
13

RSwitch

🎛 A small menubar app that allows you to switch between R versions quickly (if you have multiple versions of R framework installed).
Swift
99
star
14

newsflash

Tools to Work with the Internet Archive and GDELT Television Explorer in R
R
88
star
15

curlconverter

➰ ➡️ ➖ Translate cURL command lines into parameters for use with httr or actual httr calls (R)
R
88
star
16

darksky

☁️ R interface to the Dark Sky API [APPLE IS SHUTTING DOWN THE API 2022-12-31]
R
82
star
17

freebase

👃🏽A 'usethis'-like Package for Base R Pseudo-equivalents of 'tidyverse' Code
R
82
star
18

albersusa

Tools, shapefiles & data to work with an "AlbersUSA" composite projection in R
R
75
star
19

21-recipes

📕 An R/rtweet edition of Matthew A. Russell's Python Twitter Recipes Book
CSS
72
star
20

nominatim

🌏 Tools for Working with the 'Nominatim' API in R
R
71
star
21

hrbraddins

Additional Addins for RStudio
R
68
star
22

ggeconodist

📉 Create Diminutive Distribution Charts
R
67
star
23

decapitated

Headless 'Chrome' Orchestration in R
R
66
star
24

taucharts

📊 An R htmlwidget interface to the TauCharts javascript library
HTML
65
star
25

speedtest

📐 Measure upload/download speed/bandwidth for your network with R
R
64
star
26

ggcounty

🌐 Generate ggplot2 geom_map county maps
R
62
star
27

pluralize

An R package to "Pluralize and Singularize Any Word"
JavaScript
60
star
28

qrencoder

🔳 Make QR codes in R via libqrencode
C
59
star
29

quarto-organization-template

A Quarto RevealJS Organization Boilerplate Template You Can Clone And Modify Quickly
SCSS
59
star
30

swatches

🎨 Read, Inspect, Manipulate, and Save (ASE-only for save) Color Swatch Files
R
56
star
31

cdcfluview

😷 R package to Retrieve U.S. Flu Season Data from the CDC FluView Portal (WHO & ILINet)
R
56
star
32

rgeocodio

Tools to Work with the https://geocod.io/ API
R
56
star
33

cloc

🔢 R package to the perl cloc script (which counts blank lines, comment lines, and physical lines of source code in source files/trees/archives)
Perl
55
star
34

dtupdate

The dtupdate package has functions that try to make it easier to keep up with the non-CRAN universe
R
55
star
35

wayback

⏪ Tools to Work with the Various Internet Archive Wayback Machine APIs
R
54
star
36

orangetext

🍊📄 : An #rstats project to keep track of The 🍊 One's speeches
R
53
star
37

rstudioconf2017

Slides/code/data from rstudio:: conf 2017
ASP
52
star
38

ndjson

♨️ Wicked-Fast Streaming 'JSON' ('ndjson') Reader in R
C++
51
star
39

ggvis-maps

Examples of various kinds of maps in ggvis (with & without shiny)
R
51
star
40

iptools

🍴 A toolkit for manipulating, validating and testing IP addresses and ranges, along with datasets relating to IP addresses. While it primarily has support for the IPv4 address space, more extensive IPv6 support is intended.
Scilab
51
star
41

tidyweb

Easily Install and Load Modern Web-Scraping Packages
R
50
star
42

weatherkit

🍎🌡🔎 Obtain Historical, Current, and Predictive Weather Data from Apple WeatherKit REST API in R
R
46
star
43

pdfbox

📄◻️ Create, Maniuplate and Extract Data from PDF Files (R Apache PDFBox wrapper)
Java
46
star
44

xmlview

📃 Format, Query and Pretty Print 'HTML'/'XML' Content in R (RStudio viewer or browser)
JavaScript
46
star
45

msgxtractr

📇 Extract contents from Outlook '.msg' files in R
C
44
star
46

worldtilegrid

🔲🗺 World Tile Grid Geom for ggplot2 [WIP]
R
43
star
47

QuickLookR

macOS QuickLook plugin for R save(), saveRDS() & feather files
C
42
star
48

voteogram

U.S. House and Senate Voting Cartogram Generators in R
R
41
star
49

nifffty

Small R package to post events to IFTTT Maker channel/recipes
R
40
star
50

githubdashboard

#rstats github flexdashboard
HTML
40
star
51

overpass

ℹ️ Tools to Work With the OpenStreetMap (OSM) Overpass API in R
HTML
40
star
52

hrbragg

Typography-centric Themes, Theme Components, and Utilities for 'ggplot2' and 'ragg'.
R
39
star
53

netintel

A collection of "network intelligence" utilities for R. ASN info, IP reputation, etc.
R
39
star
54

htmlunit

🕸🧰☕️Tools to Scrape Dynamic Web Content via the 'HtmlUnit' Java Library
R
38
star
55

Rforecastio

☁️ Simple R interface to forecast.io weather data
R
38
star
56

omdbapi

R package to access the OMDB API (http://www.omdbapi.com/)
R
38
star
57

mactheknife

🦈 Various ‘macOS’-oriented Tools and Utilities in R
R
37
star
58

tdigest

Wicked Fast, Accurate Quantiles Using 't-Digests'
C
36
star
59

hrbrmisc

personal R pkg
R
35
star
60

webr-experiments

🕸️ 🧪 hrbrmstr's WebR Experiments
HTML
34
star
61

2017-year-in-review

Year in Review with R Rmd Template
34
star
62

crafter

🔬 An R package to work with PCAPs
R
33
star
63

longurl

ℹ️ Small R package for no-API-required URL expansion
R
32
star
64

greywatch

🕵🏽 macOS Big Sur desktop app to monitor active TCP connections through the lens of GreyNoise
Swift
32
star
65

ipv4-heatmap

Update to The Measurement Factory ipv4-heatmap codebase
C
32
star
66

jsonview

JSON pretty printer & viewer in R
JavaScript
30
star
67

rpwnd

🙅 The Most Benignly Malicious R Package on the Internet
R
30
star
68

statically

📸 Generate Webpage Screenshots Using the Statically API
R
28
star
69

rradar

🌊 Animate current U.S. NOAA NWS N0R Radar Images
R
27
star
70

archinfo

𖼆 Returns a list of running processes and the architecture (x86_64/arm64) they are running under.
C
26
star
71

ohq2quarto

Save an Observable HQ Notebook to a Quarto project
Rust
25
star
72

osqueryr

⁇ 'osquery' 'DBI' and 'dbplyr' Interface for R
R
25
star
73

ulid

⚙️ Universally Unique Lexicographically Sortable Identifiers in R
C++
25
star
74

webr-monaco-repl

🧪 🕸️ Monaco-powered WebR "REPL"
JavaScript
24
star
75

imprint

Create Customized 'ggplot2' and 'R Markdown' Themes for Your Organization
R
24
star
76

gdns

Tools to work with the Google DNS over HTTPS API in R
R
24
star
77

2020-george-floyd-protests

Code to collect data from various sources on the 2020 George Floyd protests.
HTML
23
star
78

fileio

⏳ Ephemeral File, Text or R Data Sharing with 'file.io'
R
23
star
79

widgetcard

Tools to Enable Easier Content Embedding in Tweets
R
23
star
80

attckr

⚔️MITRE ATT&CK Machinations in R
R
23
star
81

mgrs

🌐 An R Package to Convert 'MGRS' (Military Grid Reference System) References From/To Other Coordiante Systems
C
23
star
82

webr-app

🧪 🕸️ A Way Better Structured WebR Demo App
JavaScript
23
star
83

pubcrawl

🍺📖 Convert 'epub' Files to Text (Use https://github.com/ropensci/epubr instead)
R
22
star
84

xslt

lightweight XSLT processing package for R based on xmlwrapp
R
22
star
85

swiftr

Seamless R and Swift Integration
R
22
star
86

ggsolar

🪐 Generate "solar system" plots with {ggplot2}
R
22
star
87

facetedcountryheatmaps

Small sample Rmd to show how to make faceted country heatmaps in a couple different ways in R
HTML
22
star
88

ipapi

An R package to geolocate IPv4/6 addresses and/or domain names using ip-api.com's API
HTML
22
star
89

firasans

🔏 Fira Sans Condensed + Fira Mono Font Theme Based on hrbrthemes
R
22
star
90

drill-sergeant-rstats

📗 A Little Book About Using Apache Drill and R
R
22
star
91

slopegraph

A 'slopegraph' ('table-chart') generator in Python using Cairo/Raphaël. Currently handles a two column chart with _many_ output options. Look at the '/examples' directory for sample configurations, data files and output formats.
JavaScript
22
star
92

reveal-qmd

Chrome Extension To Reveal Observable Notebooks As Quarto QMD {ojs} Blocks & provide downloads of FileAttachments and zipped Quarto project
JavaScript
21
star
93

elpresidente

🇺🇸 Search and Extract Corpus Elements from 'The American Presidency Project'
R
21
star
94

wand

Use 'magic' to guess file types
R
21
star
95

warc

📇 Tools to Work with the Web Archive Ecosystem in R
R
21
star
96

rstudio-electron-quarto-installer

Download and install the latest macOS RStudio (electron) daily along with the latest Quarto pre-release
Shell
21
star
97

urlscan

👀 Analyze Websites and Resources They Request
R
21
star
98

wondr

Tools to Work with there CDC WONDER API in R
R
20
star
99

supercaliheatmapwidget

📅 Supercalifragilistic HTML Calendar Heatmaps
JavaScript
20
star
100

secede-2014

R dplyr/tidyr/rvest/TopoJSON tutorial using the 2014 Scotland secession vote
R
20
star