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

**URL:** https://discourse.paraview.org/t/values-for-viridis-colormap-do-not-correspond-to-those-in-matplotlib/6635
**Category:** ParaView Support
**Created:** [March 6, 2021, 12:40am UTC](https://discourse.paraview.org/t/values-for-viridis-colormap-do-not-correspond-to-those-in-matplotlib/6635 "2021-03-06T00:40:42Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![stefanv](https://discourse.paraview.org/user_avatar/discourse.paraview.org/stefanv/32/6091_2.png) [@stefanv](https://discourse.paraview.org/u/stefanv)
#### Post date: [March 6, 2021, 12:40am UTC](https://discourse.paraview.org/t/values-for-viridis-colormap-do-not-correspond-to-those-in-matplotlib/6635/1 "2021-03-06T00:40:42Z")

</div>

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:

> <https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/_cm_listed.py#L774>

---

<div class="post-metadata">

### Author: ![stefanv](https://discourse.paraview.org/user_avatar/discourse.paraview.org/stefanv/32/6091_2.png) [@stefanv](https://discourse.paraview.org/u/stefanv)
#### Post date: [March 15, 2021, 9:44pm UTC](https://discourse.paraview.org/t/values-for-viridis-colormap-do-not-correspond-to-those-in-matplotlib/6635/2 "2021-03-15T21:44:01Z")

</div>

Any thoughts on this?

---

<div class="post-metadata">

### Author: ![danlipsa](https://discourse.paraview.org/user_avatar/discourse.paraview.org/danlipsa/32/1563_2.png) [@danlipsa](https://discourse.paraview.org/u/danlipsa)
#### Post date: [March 15, 2021, 9:59pm UTC](https://discourse.paraview.org/t/values-for-viridis-colormap-do-not-correspond-to-those-in-matplotlib/6635/3 "2021-03-15T21:59:19Z")

</div>

[@Cory Quammen](mailto:cory.quammen@kitware.com) Any ideas?

---

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [March 15, 2021, 10:01pm UTC](https://discourse.paraview.org/t/values-for-viridis-colormap-do-not-correspond-to-those-in-matplotlib/6635/4 "2021-03-15T22:01:21Z")

</div>

It’s on my list of todo’s… 😊

Alan

---

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [March 16, 2021, 12:18am UTC](https://discourse.paraview.org/t/values-for-viridis-colormap-do-not-correspond-to-those-in-matplotlib/6635/5 "2021-03-16T00:18:36Z")

</div>

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](https://github.com/BIDS/colormap/blob/master/colormaps.py)”,  
“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.

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [March 16, 2021, 4:48am UTC](https://discourse.paraview.org/t/values-for-viridis-colormap-do-not-correspond-to-those-in-matplotlib/6635/6 "2021-03-16T04:48:37Z")

</div>

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](https://www.youtube.com/watch?v=xAoljeRJ3lU) where these were introduced back in 2015. Within a couple days I even [blogged](https://blog.kitware.com/use-viscm-to-design-color-maps-for-paraview-4-4/) 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](https://github.com/BIDS/colormap/blob/master/colormaps.py) which are the same as listed in [matplotlib/\_cm\_listed.py at master · matplotlib/matplotlib · GitHub](https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/_cm_listed.py#L774). 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.

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [March 16, 2021, 2:34pm UTC](https://discourse.paraview.org/t/values-for-viridis-colormap-do-not-correspond-to-those-in-matplotlib/6635/7 "2021-03-16T14:34:58Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [March 16, 2021, 4:02pm UTC](https://discourse.paraview.org/t/values-for-viridis-colormap-do-not-correspond-to-those-in-matplotlib/6635/8 "2021-03-16T16:02:55Z")

</div>

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…

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [March 16, 2021, 5:47pm UTC](https://discourse.paraview.org/t/values-for-viridis-colormap-do-not-correspond-to-those-in-matplotlib/6635/9 "2021-03-16T17:47:18Z")

</div>

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):`.
