我想从 ggthemes
中选择 colorblind_pal()
的特定颜色
这有效:
library(ggplot2)
library(ggthemes)
p <- ggplot(mtcars) + geom_point(aes(x = wt, y = mpg,
colour = factor(gear))) + facet_wrap(~am)
p + theme_igray() + scale_colour_colorblind()
现在我想为我的绘图选择 colorblind_pal()
的特定颜色。我该如何选择它们?
我尝试了以下操作但没有成功:
my_palette <- palette(c("#000000","#F0E442","#D55E00"))
p + theme_igray() + scale_colour_colorblind(my_palette)
最佳答案
您可以使用scale_color_manual
来手动指定要使用的颜色:
library(ggplot2)
library(ggthemes)
p <- ggplot(mtcars) +
geom_point(aes(x = wt, y = mpg, colour = factor(gear))) +
facet_wrap(~am) +
theme_igray() +
scale_color_manual(values = c("#000000","#F0E442","#D55E00"))
p
关于r - 在 ggthemes 中为scale_colour_colorblind()选择颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60301305/