knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" ) library(ggplot2) library(dplyr) library(ggpattern) #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Generate the pkgdown documentation #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (FALSE) { pkgdown::build_site(override = list(destination = "../coolbutuseless.github.io/package/ggpattern")) } #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Generate a tweetable gif of a bunch of examples #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (FALSE) { png_files <- list.files("vignettes/images/", pattern = "*gallery.*png", full.names = TRUE) png_files <- paste(png_files, collapse = " ") gif_files <- gsub("png", "gif", png_files) command <- paste("mogrify -resize 800x600 -format gif ", png_files) system(command) command <- paste("gifsicle --colors 256 -O=100 --delay 150 o man/figures/geom-gallery.gif ", gif_files) print(command) system(command) command <- paste("rm", gif_files) system(command) } if (FALSE) { # ffmpeg -framerate 1/2 -pattern_type glob -i '*.png' -c:v libx264 -pix_fmt yuv420p -s 800x600 ../../../ggpattern-annex/demo.mp4 }
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 instructions below.
# install.packages("remotes") remotes::install_github("coolbutuseless/ggpattern")
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.