Values for viridis colormap do not correspond to those in matplotlib?

I recently came across byte-values for the viridis colormap on Kenneth Morland’s site. These didn’t correspond to the ones in Matplotlib (the original values), and when I asked Kenneth where he got his values he said from Paraview. So, I am curious: what are the values in Paraview, and are they correct?

Here are the reference values from matplotlib, in floating point format:

Any thoughts on this?

@Cory Quammen Any ideas?

It’s on my list of todo’s… :blush:

Alan

ParaView’s version of Viridis looks correct. Here it is. Note that there is the opacity alpha within the color map (that you see when you open the Color Map Editor). This ramps from 0 to 1. So, below you see a,r,g,b. I also only cut and pasted the part of the table you present above. Note that I did reformat the table from a single, long column into rows of argb 's below.

Alan

{
“ColorSpace”: “Diverging”,
“Name”: “Viridis (matplotlib)”,
“NanColor”: [
1,
0,
0
],
“Source”: “colormap/colormaps.py at master · BIDS/colormap · GitHub”,
“License”: “CC0”,
“Creator”: “Eric Firing”,
“DefaultMap”: true,
“RGBPoints”: [
0.000000, 0.267004, 0.004874, 0.329415,
0.003922, 0.268510, 0.009605, 0.335427,
0.007843, 0.269944, 0.014625, 0.341379,
0.011765, 0.271305, 0.019942, 0.347269,
0.015686, 0.272594, 0.025563, 0.353093,
0.019608, 0.273809, 0.031497, 0.358853,
0.023529, 0.274952, 0.037752, 0.364543,
0.027451, 0.276022, 0.044167, 0.370164,
0.031373, 0.277018, 0.050344, 0.375715,
0.035294, 0.277941, 0.056324, 0.381191,
0.039216, 0.278791, 0.062145, 0.386592,

If interested, the actual table in the code is in Remoting/Views/ColorMap.json.

Stéfan, first of all thank you for the work of you and your colleagues on Viridis and the other color maps. I was fortunate to witness firsthand the SciPy talk where these were introduced back in 2015. Within a couple days I even blogged about importing the color maps generated by viscm into ParaView.

Now to the question at hand. Not to throw @Kenneth_Moreland under the bus, but ParaView’s colors for Viridis are exactly the same as those listed in colormap/colormaps.py at master · BIDS/colormap · GitHub which are the same as listed in matplotlib/_cm_listed.py at master · matplotlib/matplotlib · GitHub. Contrary to what Alan said, the first component in the table used by ParaView is a data value ranging from [0,1] which is needed because these points define control points in the color map, and they are not always evenly spaced, hence the need to explicitly include them. Perhaps those are the values that Ken has on his site.

Hmm. It looks like I do deserve to be thrown under the bus. Those values do look right. It looks like the true problem is my use of the Python colormath color conversions. Somehow converting from RGB to LAB and back changed the colors from what ParaView had.

I guess ParaView had it right and I have it wrong. I’ll have to look into it more closely.

Cory, I took an uneducated guess… :-). Thanks for clarifying.

I did take a quick look at Ken’s site, and didn’t find Ken’s Viridis values…

Yeah, this was all on me. I thought the values on my site match ParaView, but now that Cory pointed me out, I see that my generation of tables changed the values slightly. For those that care (which is probably nobody because it has nothing to do with ParaView), the problem was the Python colormath library was not using consistent illumination parameters. When I created an sRGB color and then converted it to LAB, it used a D65 illumination. When I created a LAB color directly, it used a D50 illumination when converting back to sRGB. So the colors I got were consistent but different.

I’ve spent the morning fixing my scripts, and my web site should be updated so that its colors match those of ParaView (and by proxy matplotlib). Alan, if you care, the links to csv tables with color values are the numbers next to the labels Color Tables (float):.