查看原文
其他

R语言ggplot2作图一些好看的颜色搭配

Punicagranatum 小明的数据分析笔记本 2023-03-04

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

三个颜色
image.png
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))
image.png
5个颜色
image.png
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")
image.png
8个颜色
image.png
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")
image.png

两个颜色

image.png
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")
image.png
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")
image.png

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")
image.png

这个链接里还有其他的颜色,大家也可以挑选自己喜欢的颜色,直接用snipaste这个软件来获取颜色值

欢迎大家关注我的公众号

小明的数据分析笔记本

小明的数据分析笔记本 公众号 主要分享:1、R语言和python做数据分析和数据可视化的简单小例子;2、园艺植物相关转录组学、基因组学、群体遗传学文献阅读笔记;3、生物信息学入门学习资料及自己的学习笔记!


您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存