这些颜色来自于网页链接 https://www.royfrancis.com/elegant-scientific-graphs-learning-from-examples/,我使用snipaste软件把颜色弄下来了,记录一下,自己备用,也分享给大家
三个颜色

library(ggplot2)
colors_1<-c("#e20612","#ffd401","#00b0eb")
df1<-data.frame(x=letters[1:3],y=1:3)
library(ggplot2)
ggplot(data=df1,aes(x,y))+
geom_col(aes(fill=x))+
theme_bw()+
scale_fill_manual(values = colors_1)+
geom_label(aes(label=colors_1))+
scale_y_continuous(expand = c(0,0),
limits = c(0,4))

5个颜色

colors_3<-c("#ef1828","#f88421","#ffbc14",
"#00bdcd","#006b7b")
df3<-data.frame(x=letters[1:5],
y=1:5)
ggplot(data=df3,aes(x,y))+
geom_col(aes(fill=x))+
theme_bw()+
scale_fill_manual(values = colors_3)+
geom_label(aes(label=colors_3))+
scale_y_continuous(expand = c(0,0),
limits = c(0,6))+
theme(legend.position = "none")

8个颜色

colors_2<-c("#cc340c","#e8490f","#f18800","#e4ce00",
"#9ec417","#13a983","#44c1f0","#3f60aa")
df2<-data.frame(x=letters[1:8],
y=1:8)
ggplot(data=df2,aes(x,y))+
geom_col(aes(fill=x))+
theme_bw()+
scale_fill_manual(values = colors_2)+
geom_label(aes(label=colors_2))+
scale_y_continuous(expand = c(0,0),
limits = c(0,9))+
theme(legend.position = "none")

两个颜色

colors_4<-c("#156077","#f46f20")
df4<-data.frame(x=letters[1:2],
y=1:2)
ggplot(data=df4,aes(x,y))+
geom_col(aes(fill=x))+
theme_bw()+
scale_fill_manual(values = colors_4)+
geom_label(aes(label=colors_4))+
scale_y_continuous(expand = c(0,0),
limits = c(0,3))+
theme(legend.position = "none")

colors_5<-c("#4da0a0","#9b3a74")
ggplot(data=df4,aes(x,y))+
geom_col(aes(fill=x))+
theme_bw()+
scale_fill_manual(values = colors_5)+
geom_label(aes(label=colors_5))+
scale_y_continuous(expand = c(0,0),
limits = c(0,3))+
theme(legend.position = "none")

6个颜色
colors_6<-c("#3cb346","#00abf0","#d75427",
"#2e409a","#942d8d","#eeb401")
df6<-data.frame(x=letters[1:6],
y=1:6)
ggplot(data=df6,aes(x,y))+
geom_col(aes(fill=x))+
theme_bw()+
scale_fill_manual(values = colors_6)+
geom_label(aes(label=colors_6))+
scale_y_continuous(expand = c(0,0),
limits = c(0,6))+
theme(legend.position = "none")

这个链接里还有其他的颜色,大家也可以挑选自己喜欢的颜色,直接用snipaste这个软件来获取颜色值
欢迎大家关注我的公众号
小明的数据分析笔记本
小明的数据分析笔记本 公众号 主要分享:1、R语言和python做数据分析和数据可视化的简单小例子;2、园艺植物相关转录组学、基因组学、群体遗传学文献阅读笔记;3、生物信息学入门学习资料及自己的学习笔记!
网友评论