Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in R Programming by (7.3k points)

I'm currently using scale_brewer() for fill and these look beautiful in color (on-screen and via color printer) but print relatively uniformly as greys when using a black and white printer. I searched the online ggplot2 documentation but didn't see anything about adding textures to fill colors. Is there an official ggplot2 way to do this or does anyone have a hack that they use? By textures I mean things like diagonal bars, reverse diagonal bars, dot patterns, etc that would differentiate fill colors when printed in black and white.

1 Answer

0 votes
by

You can use the colorbrewer palettes in the scale_fill_brewer to change fill but It's not currently possible to add textures because grid (the graphics system that ggplot2 uses to do the actual drawing) doesn't support textures.

To change the fill palette:

ggplot(diamonds, aes(x=cut, y=price, group=cut))+

  geom_boxplot(aes(fill=cut))+scale_fill_brewer(palette="YlOrRd")

image

To find various colorbrewer palettes, you can go to color brewer webpage http://colorbrewer2.org/

Browse Categories

...