在阅读this question时,我开始考虑是否可以将颜色转换为模仿平均灰度打印机(假设您的屏幕已校准)?找到可接受的近似值可以节省纸张。
例如,如何转换这些颜色以查看是否可以在纸上区分浅蓝色和深蓝色和红色?
temp <- rgb2hsv(239, 138, 98, maxColorValue=255)
Rl <- hsv(h = temp[1,], s = 0.5, v = 1)
Rd <- hsv(h = temp[1,], s = 0.5, v = 0.4)
temp <- rgb2hsv(103, 169, 207, maxColorValue=255)
Cl <- hsv(h = temp[1,], s = temp[2,], v = 1)
Cd <- hsv(h = temp[1,], s = temp[2,], v = 0.4)
plot(1:4, type = "p", col = c(Rl, Rd, Cl, Cd), pch = 19, cex = 8, xlim = c(0,5), ylim = c(0,5))
答案 0 :(得分:4)
使用色度设置为零的HCL调色板创建无法区分人眼的灰度值。
library(colorspace)
n <- 10
cols <- rainbow_hcl(n)
plot(seq_len(n), cex = 5, pch = 20, col = cols)
greys <- rainbow_hcl(n, c = 0)
plot(seq_len(n), cex = 5, pch = 20, col = greys)
如果您想使用原始颜色生成灰色,请使用scales
包。
library(scales)
greys2 <- col2hcl(cols, c = 0)
plot(seq_len(n), cex = 5, pch = 20, col = greys2)
答案 1 :(得分:2)
TeachingDemos包中的col2grey
(和/或col2gray
)函数使用一种常用方法来执行此操作。我们的想法是看看你的颜色在以灰度而不是彩色打印或复制时的样子。
答案 2 :(得分:2)
`colorspace包中的desaturate()
函数也可用于仅将颜色转换为灰度级。这会在颜色的HCL(或极性CIELUV)表示中折叠色度(色彩)。
plot(1:4, type = "p",
col = colorspace::desaturate(c(Rl, Rd, Cl, Cd)),
pch = 19, cex = 8, xlim = c(0,5), ylim = c(0,5))
答案 3 :(得分:0)
您可以使用here概述的3种转换算法中的一种,并确定它们是否超出您认为过于相似的任何容差。