【问题标题】:How to find out which colours are in a colour palette如何找出调色板中的颜色
【发布时间】:2019-03-20 15:29:27
【问题描述】:

我正在使用 ggplot2 用scale_color_brewer(palette="Dark2") 绘制一个简单的图表。我通常喜欢调色板,但我想改变我的情节的一行。我想我需要使用scale_color_manual。我可以通过这种方式更改颜色,但是如何找出“Dark2”主题中使用了哪些颜色?除了一个,我想保留所有。

【问题讨论】:

标签: r ggplot2


【解决方案1】:

您可以使用RColorBrewer

library(RColorBrewer)

# Put all the color values (in hex format) from Dark2 into a vector
myPal <- brewer.pal(8,"Dark2")

# Remove whichever color you don't want
myPal <- myPal[-7]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-26
    • 1970-01-01
    • 2011-08-14
    • 1970-01-01
    • 2012-07-05
    • 1970-01-01
    • 2020-11-24
    • 2011-08-19
    相关资源
    最近更新 更多