[英]chose colors for scale_colour_colorblind() in ggthemes
I would like to chose specific colors of the colorblind_pal()
from ggthemes
我想从
ggthemes
选择ggthemes
colorblind_pal()
特定颜色
This works:这有效:
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()
Now I would like to chose specific colors of the colorblind_pal()
for my plot.现在我想为我的情节选择
colorblind_pal()
特定颜色。 How can I chose them?我该如何选择它们?
I tried following with no success:我尝试了以下但没有成功:
my_palette <- palette(c("#000000","#F0E442","#D55E00"))
p + theme_igray() + scale_colour_colorblind(my_palette)
You could use scale_color_manual
in order to manually specify the colors to use:您可以使用
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
Since you already have the colors, you can just use scale_color_manual
:因为你已经有了颜色,你可以只使用
scale_color_manual
:
library(ggthemes)
library(ggplot2)
COLS=colorblind_pal()(8)
COLS = COLS[c(1,5,7)]
p <- ggplot(mtcars) + geom_point(aes(x = wt, y = mpg,
colour = factor(gear))) + facet_wrap(~am)
p + theme_igray() + scale_colour_manual(values=COLS))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.