rm(list = ls())
install.packages("RColorBrewer")
library(RColorBrewer)
# 绘制 RColorBrewer 调色板
display.brewer.all()
head(brewer.pal.info)
image.png
# 通过指定名字来查看调色板
display.brewer.pal(n = 8, name = 'RdBu')
# 十六进制颜色规格
brewer.pal(n = 8, name = "RdBu")
[1] "#B2182B" "#D6604D" "#F4A582" "#FDDBC7" "#D1E5F0" "#92C5DE" "#4393C3" "#2166AC"
# RColorBrewer绘制条形图
barplot(c(2,5,7), col=brewer.pal(n = 3, name = "RdBu"))
TIPS:
连续型调色板,适用于从低到高(渐变)的有序数据。
Blues, BuGn, BuPu, GnBu, Greens, Greys, Oranges, OrRd, PuBu, PuBuGn, PuRd, Purples, RdPu, Reds, YlGn, YlGnBu YlOrBr, YlOrRd
离散型调色板,同时强调中端临界值和数据范围两端的极端值。
BrBG, PiYG, PRGn, PuOr, RdBu, RdGy, RdYlBu, RdYlGn, Spectral
定性调色板,适用于名义型或分类型变量。 它们并不代表组之间的大小差异。
Accent, Dark2, Paired, Pastel1, Pastel2, Set1, Set2, Set3
网友评论