ggpattern
provides custom ggplot2
geoms which support filled areas with
geometric and image-based patterns.
Reading the articles/vignettes on the package website is probably the best way to get started.
pattern_alpha
) You can install the development version from GitHub with the following instructions:
# install.packages("remotes")
remotes::install_github("trevorld/ggpattern")
You can install the CRAN release version using:
install.packages("ggpattern")
Do note though that due to CRAN size limitations the CRAN version omits several vignettes that are contained in the development version.
An installation error is highly unlikely to be an issue with {ggpattern}
itself. Please don't open up a Github Issues unless you are sure it is an issue with {ggpattern}
itself. If you have an error installing the package we strongly suggest that you look at all your error messages more closely to figure out which package dependency is failing to install and why. See https://thomasadventure.blog/posts/install-r-packages/ for more info on installing R packages.
geom_col()
.{ggpattern}
version of the geom e.g. ggpattern::geom_col_pattern()
instead of ggplot2::geom_col()
pattern
to your choice of pattern e.g pattern = 'stripe'
,
and set other options using pattern_*
aestheticsdf <- data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1))
ggplot(df) +
geom_col_pattern(
aes(level, outcome, pattern_fill = level),
pattern = 'stripe',
fill = 'white',
colour = 'black'
) +
theme_bw(18) +
theme(legend.position = 'none') +
labs(
title = "ggpattern::geom_col_pattern()",
subtitle = "pattern = 'stripe'"
) +
coord_fixed(ratio = 1/2)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.