What is the status of Matplotlib CMYK color support?

I was researching the options for easy conversion of Matplotlib graphics to print-ready formats (i.e. vector files in cmyk color mode) and found this old thread, but no notice of any later developments.

Now when looking at the files the pdf and svg backends output (using Matplotlib 2.1.2), I noticed that the pdf backend actually does convert gray and black to grayscale colors, which means that Matplotlib pdf:s safely can be used for print output. I was not able to find any documentation about this!

Acrobat preview of Matplotlib pdf where a line specified as grey is interpreted as 45% process black, texts are 100% proces black:

The svg backend on the other hand outputs the same graphic with text and grey lines as rgb colors.

While this feature of the pdf backend fixes the critical issue of texts printing poorly, it would still be very useful to be able to specify cmyk colors directly as values (even for just vector graphic elements). It is not for instance possible to choose a rgb value that would convert to 100 % cyan.

This might be possible to implement without creating full internal support for cmyk colors, which understandably is complex and in many cases unnecessary. Perhaps something like a separate cmyk color object where the percentages would be applied on export in the backend?

As an aside, R has cmyk output but leaves raster graphics as rgb; also as it is done as a conversion from sRGB it is not possible to define specific cmyk color percentages. postscript function - RDocumentation

This used to be an issue in the bad old days, but I think most publishers realize this is a nonsense requirement in 2019 when 99% of the readers read PDFs. Every time I sent a published CMYK, it ended up looking terrible in print and PDF, whereas if I sent RGB it looked fine. Thats because the print companies are typically really good at doing color conversion that works well for their machines, so its questionable practice to push the burden of color management down to authors. Just my opinion, I’d be curious what others think.

1 Like

Indeed, I can see this no longer being much of an issue for journal submissions.

The cases where direct control of process colors are necessary are maybe a bit more marginaI in the context of how Matplotlib mostly is used. I work as an information designer and our studio frequently makes graphics and final printing products, and for this type of workflows direct specification of cmyk values would be a helpful time-saver. A typical situation is where a graphic is to use pre-specified brand colors of a client which then ought to be defined in cmyk to print correctly. For printing e.g. a 100% cyan grid also looks better than one with component colors.

1 Like

Sounds like you understand color support better than I do. From a Matplotlib point of view, I think having a cmyk color spec for artists would be really hard as all our colours are rbga down to really low levels. We could do a conversion at write time but that isn’t really what you want because, as you say, cyan doesn’t have a pure RGB equivalent.

Is it possible to directly manipulate the color codes in eps?

1 Like