如何添加纹理以填充ggplot2中的颜色 [英] How to add texture to fill colors in ggplot2
问题描述
我当前正在使用scale_brewer()
进行填充,这些颜色看起来很漂亮(在屏幕上和通过彩色打印机),但是在使用黑白打印机时,它们相对均匀地打印为灰色.我搜索了在线ggplot2
文档,但未发现有关添加纹理以填充颜色的任何信息.是否有官方的ggplot2
方法来执行此操作,或者有人使用他们的hack吗?所谓纹理,是指诸如对角线,反向对角线,点图案之类的东西,当以黑白打印时,它们可以区分填充颜色.
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.
推荐答案
ggplot可以使用Brebrewer调色板.其中一些是影印"友好的.那么这样的东西可能对您有用吗?
ggplot can use colorbrewer palettes. Some of these are "photocopy" friendly. So mabe something like this will work for you?
ggplot(diamonds, aes(x=cut, y=price, group=cut))+
geom_boxplot(aes(fill=cut))+scale_fill_brewer(palette="OrRd")
在这种情况下,OrRd是在colorbrewer网页上找到的调色板: http://colorbrewer2.org/ >
in this case OrRd is a palette found on the colorbrewer webpage: http://colorbrewer2.org/
复印友好:这表明 给定的配色方案将 承受黑色和白色 影印.分流方案可以 无法成功复印. 亮度差异应为 保留有顺序方案.
Photocopy Friendly: This indicates that a given color scheme will withstand black and white photocopying. Diverging schemes can not be photocopied successfully. Differences in lightness should be preserved with sequential schemes.
这篇关于如何添加纹理以填充ggplot2中的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!