如何在GGR绘图中从调色板中选择特定颜色
我正在绘制一个类似于ggplot的条形图: 但我不能轻易地看到投影仪上最亮的色条 我想跳过“蓝色”调色板中最浅的蓝色,而是使用2:9或3:9的颜色进行绘图 我以iris数据集为例:如何在GGR绘图中从调色板中选择特定颜色,r,ggplot2,R,Ggplot2,我正在绘制一个类似于ggplot的条形图: 但我不能轻易地看到投影仪上最亮的色条 我想跳过“蓝色”调色板中最浅的蓝色,而是使用2:9或3:9的颜色进行绘图 我以iris数据集为例: df <- data.frame(iris,petal.colour=c("red","blue"), country=c("UK","France","Germany")) ggplot(df, aes(petal.colour,Sepal.Length))+ geom_bar(stat = "ide
df <- data.frame(iris,petal.colour=c("red","blue"), country=c("UK","France","Germany"))
ggplot(df, aes(petal.colour,Sepal.Length))+
geom_bar(stat = "identity",aes(fill=country))+
facet_wrap(~Species, ncol=3)+
scale_fill_brewer(palette = "Blues" ,
labels = c("French Flower", "German Flower","UK Flower"))+
theme_bw(base_size=18)
df这里有一种方法,将调色板预定义为四色蓝色调色板的最后3种颜色:
my_colors <- RColorBrewer::brewer.pal(4, "Blues")[2:4]
ggplot(df, aes(petal.colour,Sepal.Length))+
geom_bar(stat = "identity",aes(fill=country))+
facet_wrap(~Species, ncol=3)+
scale_fill_manual(values = my_colors,
labels = c("French Flower", "German Flower","UK Flower"))+
theme_bw(base_size=18)
my_colorsRColorBrewer::brewer.pal(9,'Blues')的可能重复项
给出了“Blues”中所有九种颜色的向量。为了澄清,在我标记为重复项的问题中,我们在调色板中添加了一种颜色。在您的情况下,您正在删除一种颜色。但添加或删除向量的元素也是一样的