Patterned Fills for 'ggplot2' and 'grid' Graphics

Provides geometric patterns to replace solid color fills in statistical graphics. These patterns ensure figures remain distinguishable when viewed by colorblind readers or when printed in black and white. The included patterns can be customized in terms of scale, rotation, color, fill, line type, and line width. Compatible with the 'ggplot2' package as well as 'grid' graphics.


fillpattern fillpattern logo

cran conda downloads covr

fillpattern provides geometric patterns to replace solid color fills in statistical graphics. These patterns ensure figures remain distinguishable when viewed by colorblind readers or when printed in black and white.

Compared to the similar ggpattern package, fillpattern:

  • Has no dependencies beyond base R and ggplot2.
  • Works with ggplot2::geom_* functions.
  • Focuses on simple geometric patterns.

Installation

# Install the latest stable version from CRAN:
install.packages("fillpattern")

# Or the development version from GitHub:
install.packages("pak")
pak::pak("cmmr/fillpattern")

Usage

Simply add scale_fill_pattern() to your ggplot.

library(ggplot2)
library(fillpattern)

ggplot(mpg, aes(x = class, color = drv, fill = drv)) +
  geom_bar() +
  scale_fill_pattern()

Works with geom_bar(), geom_boxplot(), geom_violin(), and other geom_* functions that accept a fill aesthetic.

grid grobs

Set fill = fill_pattern() in the grob’s graphical parameters.

library(grid)
library(fillpattern)

grid.newpage()
grid.circle( gp = gpar(fill = fill_pattern("grid")), x = 1/4, r = 3/8)
grid.rect(   gp = gpar(fill = fill_pattern("fish")), width = 1/5, height = 3/4)
grid.polygon(gp = gpar(fill = fill_pattern("brick")), x = c(6,7,5)/8, y = c(7,1,1)/8)

Basic Patterns

Use any of these pattern names in fill_pattern() or scale_fill_pattern().

Modified Patterns

For each basic pattern, you can specify the foreground color, background color, line width/style, tile size/rotation, and more through arguments to fill_pattern() and scale_fill_pattern().

Most modifications can be specified as part of the pattern name (shown below).

For additional details, see the fill_pattern() and scale_fill_pattern() reference pages.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("fillpattern")

1.0.4 by Daniel P. Smith, 25 days ago


https://cmmr.github.io/fillpattern/, https://github.com/cmmr/fillpattern


Report a bug at https://github.com/cmmr/fillpattern/issues


Browse source code at https://github.com/cran/fillpattern


Authors: Daniel P. Smith [aut, cre] (ORCID: , Alkek Center for Metagenomics and Microbiome Research [cph, fnd]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports ggplot2, grDevices, grid, methods, utils

Suggests ragg, testthat


Imported by rbiom.


See at CRAN