odd appearance of colors with viridis in PDFs viewed by Preview v. Adobe

Viewed 139

I've been creating heatmaps using heatmap.2() in R.

I'm using the viridis() color scale.

I used pdf() to create the output.

As you can see the color key looks different when viewing the PDF file using Adobe Acrobat (top panel) v. using Preview (bottom panel) in OS X (version 11.3.1). The Adobe Acrobat appearance is closer to what I expect. The colors in Preview appear washed out and undersaturated.

Has anyone else had this experience?

comparison of color in Adobe Acrobat v. Preview

Code added after original post:

The following code generates the "washed out" color key in the heatmap:

library ('viridis')
library('gplots')
test.matrix <- matrix(ncol=25, nrow=9, -4:4)
breaks <- seq(-4,4,0.5)
pdf(file='heatmap.pdf', width=10, height=6)
heatmap.2(test.matrix, density.info = 'none',  trace='none', 
  Colv = F, Rowv = F, dendrogram = 'none', 
  col=viridis(length(breaks)-1), breaks=breaks 
          )
dev.off()
2 Answers

Adobe Reader (default settings) does not display plots exactly as they are stored in the file. You can play around with the settings at Edit > Preferences > Page Display. Try to open the file with another PDF reader and you probably see a difference. The Adobe program also makes thin lines appear thicker, smoothes low resolution images, fills gaps between nearby lines etc.

Visual comment - not an answer for bounty.

As per Jon-Spring comment above.

It is not a difference per app as such, here is the exact same input file with colour profiles toggled on and off on the same screen. Note my simulation unlike the OP affects the Pixelated Text. I am using an RGB image from 1st example above rather than Coloured Objects However it shows the underlying difference.

enter image description here enter image description here

I would thus suggest looking for any colour profile related settings in Preview

Related