0 votes
1 view
in R Programming by (6.5k 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 (25.3k points)

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/

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...