R 中的配色方案?

发布于 2024-09-25 22:27:13 字数 98 浏览 0 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

淡淡的优雅 2024-10-02 22:27:13

正如 deinst 提到的,RColorBrewer 非常有用 - 尽管它是为地图设计的 em> 而不是折线图。

许多其他软件包提供调色板帮助:

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:

as can be seen from a quick query on 'palette' at rseek.org.

深海里的那抹蓝 2024-10-02 22:27:13

生成调色板的最简单方法是使用基本 grDevices 包中的通用函数:

rainbow()
topo.colors()
terrain.colors()
heat.colors()

如果所需的颜色数量不超过 7-8 种,这些函数非常有用。唯一必要的参数是调色板中的颜色数量。

还有gray()函数可用于生成各种灰度。

或者你可以这样做:

pal <- colorRampPalette(c("red", "blue", "plum"))
barplot(t(as.matrix(mydf)), beside=TRUE, col=pal(3))

The easiest way to generate a palette is using generic functions from the basic grDevices package:

rainbow()
topo.colors()
terrain.colors()
heat.colors()

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:

pal <- colorRampPalette(c("red", "blue", "plum"))
barplot(t(as.matrix(mydf)), beside=TRUE, col=pal(3))
我是男神闪亮亮 2024-10-02 22:27:13

查看 RColorBrewer 包。这些颜色没有命名,但我认为它们与您正在寻找的颜色很接近。

Look at the RColorBrewer package. The colors are not named, but I think that they are close to what you are looking for.

云淡风轻 2024-10-02 22:27:13

使用 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.

缘字诀 2024-10-02 22:27:13

没有人提到这一点,但看看定义默认托盘的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文