栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > R语言

R语言内置颜色色板+生成代码

R语言 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

R语言内置颜色色板+生成代码

R语言内置颜色参照色板
日常使用中, 想用一些R语言内置颜色, 网上始终没有找到相对齐全的内置色板, 于是自己写了一个.

R语言内置颜色总共657种, 文中代码共生成560种颜色, 去掉了部分Grey渐变色.
代码如下:

// RColors-568
col <- 8
ids <- c(1:263, 361:657)
line <- ceiling(length(ids)/col)
cls <- colors()[ids]
filename <- "RColors.png"
png(filename, width = 1600, height = 3200, units = "px")
par(mar=c(0,0,0,0))
plot(0, 0, type = "n", xlim = c(0, 1), ylim = c(0, 1), axes = FALSE, xlab = "", ylab = "")
rect(rep((0:(col - 1)/col),line), sort(rep((0:(line - 1)/line),col),decreasing=T), rep((1:col/col),line),
     sort(rep((1:line/line),col),decreasing=T), border = "grey80", col=cls[seq(1,line*col)])
text(rep((0:(col - 1)/col),line)+0.062, col = "grey20",
     sort(rep((0:(line - 1)/line),col), decreasing=T)+0.007, paste0(ids,"-",cls)[seq(1,line*col)], cex=1.5)
dev.off()
print(paste0("Saved to ", getwd(), "/", filename))

生成的色板图片:

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/855663.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号