R 中的配色方案?
R
有调色板吗?
换句话说,我正在寻找一组大约 6 个颜色名称,这些颜色名称在图表或绘图中可以很好地搭配在一起;也许有一些类似的预定义方案?
Does R
have color palettes?
In other words, I am looking for an array of 6 or so color names that go well together in a graph or plot; maybe there are some predefined schemes like that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
正如 deinst 提到的,RColorBrewer 非常有用 - 尽管它是为地图设计的 em> 而不是折线图。
许多其他软件包提供调色板帮助:
colorpanel()
, <代码>rich.colors(), ...从 rseek.org 上的“调色板”。
RColorBrewer, as mentioned by deinst, is very useful -- even though it was designed for maps rather than line charts.
A number of other packages offer help with palettes:
colorpanel()
,rich.colors()
, ...as can be seen from a quick query on 'palette' at rseek.org.
生成调色板的最简单方法是使用基本 grDevices 包中的通用函数:
如果所需的颜色数量不超过 7-8 种,这些函数非常有用。唯一必要的参数是调色板中的颜色数量。
还有
gray()
函数可用于生成各种灰度。或者你可以这样做:
The easiest way to generate a palette is using generic functions from the basic grDevices package:
These are useful if the desired number of colors doesn't exceed 7-8. The only necessary argument is the number of colors in palette.
There is also
gray()
function which can be used to generate various schades of gray.Or you could do something like:
查看 RColorBrewer 包。这些颜色没有命名,但我认为它们与您正在寻找的颜色很接近。
Look at the RColorBrewer package. The colors are not named, but I think that they are close to what you are looking for.
使用 RColorBrewer 之前,请访问此页面。在顶部选择数据类的数量,然后定义数据的性质。您可能还会发现此页面很有用。
Visit this page before using RColorBrewer. Select the number of your data classes in the top and then define the nature of your data. You may also find this page useful.
没有人提到这一点,但看看定义默认托盘的
palette
函数 (?palette
)。palette()[1:6]
为您提供前六种默认颜色。No one mention this but look at
palette
function (?palette
) which define default pallet.palette()[1:6]
gives you first six default colours.