[R] RGB -> CYMK, with consistent colors

Martin Møller Skarbiniks Pedersen tr@xp|@yer @end|ng |rom gm@||@com
Mon Nov 30 21:15:10 CET 2020


On Sun, 29 Nov 2020 at 20:55, Derek M Jones <derek using knosof.co.uk> wrote:
[...]
>
> library("colorspace")
>
> two_c=rainbow(2)
> x=runif(20)
> y=runif(20)
> plot(x, y, col=two_c[2])
> pdf(file="cmyk.pdf", colormodel="cmyk")
> plot(x, y, col=two_c[2])
> dev.off()

rainbow(2) gives two RGB-colours: #FF0000 (=pure red) and #00FFFF (=pure
cyan).
So it should be no problem to match two_c[2] perfect in CMYK-colourspace

However after some testing.
I totally agree that CMYK handling in R using pdf(..., colormodel = "cmyk")
is not correct.

One solution:
Output in tiff or png instead and then convert to CMYK using external tools.

Try this:
png("plot.png")
plot(runif(10), runif(10), col =  ""#00FFFF") # cyan
dev.off()

And then convert plot.png using:
https://www.online-utility.org/image/convert/to/CMYK

Regards
Martin

	[[alternative HTML version deleted]]



More information about the R-help mailing list