For this post, we need to load ggpattern, ggplot2 and hrbrthemes (for better looking chart).
With ggplot2 and
the geom_bar()
function, we can easily create
simple barchart:
In various cases, you can be obliged to have black and white charts. However, this does not imply that only can use uniform colors!
Actually, you can add textures to your chart elements and make them more visually apealling thanks to the ggpattern library.
This package has a geom_col_pattern()
function for this
specific use case!
The following arguments customize the appearance of the patterns:
fill = 'white'
: The base fill color of the
bars (behind the pattern) is white.
colour = 'black'
: The border color
of the bars is black.
pattern_density = 0.5
: The density
of the pattern inside the bars.
pattern_fill = 'black'
: The color of the
pattern itself.
pattern_colour = 'darkgrey'
: The secondary
color used in the pattern.
This post explained how to create a textured black and white barchart using the ggpattern library. For more of this package, see the dedicated section or the barplot section.
👋 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! 🔥