如何添加纹理来填充ggplot2中的颜色? [英] How to add texture to fill colors in ggplot2?

查看:646
本文介绍了如何添加纹理来填充ggplot2中的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用 scale_brewer()进行填充,这些颜色看起来很漂亮(在屏幕上和通过彩色打印机),但在使用黑色和白色打印机。我搜索了在线的 ggplot2 文档,但没有看到任何有关添加纹理来填充颜色的信息。有没有官方的 ggplot2 方式来做到这一点,还是有人有他们使用的黑客?通过纹理我的意思是像对角线条,反斜杠,点图案等,这些区别填充颜色时,将在黑色和白色打印。 解决方案

ggplot可以使用colorbrewer调色板。其中一些是影印友好的。所以mabe这样的东西会对你有用吗?

  ggplot(diamonds,aes(x = cut,y = price,group = cut))+ 
geom_boxplot(aes(fill = cut))+ scale_fill_brewer(palette =OrRd)


$ b在这种情况下,$ b

OrRd是在colorbrewer网页上找到的调色板: http://colorbrewer2.org/


复印件友善:这表示
给定配色方案将
承受黑白
复印。分流计划可以
不能成功复印。
轻量级差异应为
,并使用顺序方案保存。



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 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")

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆