Adding patterns or textures to geom_bar() / geom_col() bars?

On occasion, I have the need for some kind of pattern or textures for geom_bar() / geom_col() bars (i.e., for black-and-white printing). For example, the following can be hard for some people to view:

library(ggplot2)
library(dplyr, warn.conflicts=FALSE)
library(tidyr)

d <- iris %>% 
    group_by(Species) %>% 
    summarize_all(mean) %>% 
    gather(key, val, -Species)

ggplot(d, aes(x = Species, y = val, fill = key)) +
    geom_col(position = "dodge") +
    scale_fill_grey()

There have been good questions and answers on Stack Overflow (also here, but the solutions are complicated and basically involve creating the patterns or textures by hand. I'm wondering if anyone has general ideas or suggestions or new approaches to solving this problem in a different way. Oftentimes when I think I can't do something with ggplot2, it means changing how I think about addressing it - but other (rare) times it just isn't implemented yet!

2 Likes

OK, so I am 90% I have seen someone do this…and I believe it was a pattern that involved cats. @maelle, was that you? Does that ring any bells?

1 Like

Extent of my expertise = http://www.masalmon.eu/2017/02/19/babarplot/ :joy:

3 Likes

Hey,
Punny or not, these are definitely patterns! :stuck_out_tongue_winking_eye:

2 Likes

@jmichaelrosenberg I hope you didn't miss https://github.com/clauswilke/ggtextures :wink:

1 Like