The hrbrthemes
package in R is
a powerful extension of the ggplot2
package. It aims to provide opinionated themes and
typography to make your ggplot2 plots more visually appealing
and publication-ready.
This post will delve into the key
features of hrbrthemes
, offering a comprehensive
set of graph examples and explanations.
{hrbrthemes}
The hrbrthemes
package in R serves as a valuable
extension to the renowned ggplot2
package. Created by Bob Rudis, hrbrthemes
offers a
collection of opinionated themes and typography
settings that aim to elevate the visual appeal of your ggplot2
plots. Whether you are a data scientist, a researcher, or anyone
interested in data visualization, this package helps you create
publication-quality plots with minimal effort.
The package is particularly useful for those who want to create publication-quality plots without spending too much time on customization. It provides a set of themes that are not only visually appealing but also adhere to good visualization practices.
✍️ author → Bob Rudis
📘 documentation → github
⭐️ more than 1000 stars on github
Before diving into the features, let’s discuss how to get started
with hrbrthemes
. The package can be easily installed from
CRAN using the install.packages
function. Once installed,
you can load it into your R session along with ggplot2 to start
enhancing your plots.
The hrbrthemes
package offers a collection of
opinionated themes that can be applied to your ggplot2
plots. These themes are designed to be visually appealing and
publication-ready. They come with a set of pre-configured
settings like font sizes, colors, and grid lines that adhere to
good visualization practices.
Here’s how you can apply the theme_ipsum()
to a scatter
plot:
One of the standout features of hrbrthemes
is its
collection of opinionated themes. These themes, such as
theme_ipsum()
, theme_modern_rc()
, and
theme_ft_rc()
, are designed to be visually appealing and
publication-ready. They come with a set of pre-configured settings like
font sizes, colors, and grid lines that adhere to good visualization
practices.
Here’s how you can apply the theme_modern_rc()
to a
scatter plot:
Another key feature of hrbrthemes
is its typography
settings. These settings allow you to customize the fonts and font sizes
of your plots. For example, you can change the font family of your plot
to serif
and increase the font size of the axis labels to
14 points.
hrbrthemes
also offers a set of grid line settings that
allow you to customize the grid lines of your plots.
For example, you can change the color of the grid lines to
lightblue
and increase the thickness of the grid lines to
1.2 points. We have to use the theme()
function to apply
these settings, to both the major and minor grid
lines.
The hrbrthemes
package also offers a set of
custom colors that can be used in your plots. You can
use functions such as scale_color_ipsum()
and
scale_fill_ipsum()
to apply these colors to your plots. For
example, you can use the scale_color_ipsum()
function to
apply the ipsum_blue()
color to the points in a scatter
plot.
hrbrthemes
also offers a set of percent and
comma scales that can be used in your plots. These scales allow
you to format the axis labels of your plots to include a percent sign or
a comma. For example, you can use the scale_x_percent()
function to format the x-axis labels of a scatter plot to include a
percent sign.
The hrbrthemes
package is a must-have for anyone looking
to create visually appealing, publication-quality plots in R. Its
opinionated themes and enhanced typography settings make it easier than
ever to produce stunning visualizations with ggplot2. Whether you are a
seasoned data visualization expert or a beginner,
hrbrthemes
offers something for everyone.
👋 After crafting hundreds of R charts over 12 years, I've distilled my top 10 tips and tricks. Receive them via email! One insight per day for the next 10 days! 🔥