R语言有大量的内置色彩供我们使用,具体可以使用colors()提取色彩名称,
colors(F)不去重有657种,colors(T)去重有502种,此处绘制去重的色彩图
column <- 8
color <- colors(T)
index <- seq(length(color))
row <- ceiling(length(color)/column)
xleft <-rep(0:(column - 1)/column,row)[index]
ybottom <- sort(rep(0:(row - 1)/row,column),decreasing=T)[index]
xright <- rep(1:column/column,row)[index]
ytop <- sort(rep(1:row/row,column),decreasing=T)[index]
par(mar=c(0,0,0,0))
plot(x=0, y=0, type = "n", xlim = c(0, 1), ylim = c(0, 1), axes = FALSE, xlab = "", ylab = "")
rect(xleft,ybottom,xright,ytop,
border = "grey80",
col=color)
text(x=xleft+0.5/column,
y=ybottom+0.5/row,
labels = paste0(index,"-",color),
col = "grey20",
cex=1.5)
代码参考自:https://blog.csdn.net/weixin_44331529/article/details/85369232
网友评论