Use viscm to design color maps for ParaView 4.4
Update: Viridis and three other color maps with similar design parameters are now included in ParaView 5.0!
This week at SciPy2015 I attended the talk by Stéfan van der Walt and Nathaniel Smith on designing a better default color map for Python (you can view a recording of the talk here). matplotlib’s current default color map, shown below, is based on the rainbow color map, which has been shown to actively mislead viewers in their interpretation of data.
Smith and van der Walt’s talk laid out a few properties desired in a new default color map. It should be:
- Perceptually uniform in terms of uniform changes between successive colors in the map (even if printed in black and white)
- Accessible to color blind viewers (5-10% of males of European descent)
The proposed default color map, named viridis, looks like this:
This is a vast improvement over the jet colormap in terms of perceptual uniformity, accessibility to color blind viewers, and conversion to black and white.
But why should matplotlib have all the fun? Attached is a JSON file that can be imported into ParaView 4.4 (coming later this summer; bleeding edge nightly builds are available now) and later. To import this color map, open up the Color Map Editor and click on the “Choose preset” button. In the dialog that appears, choose the “Import” button, and select the file paraview_cmap.json. Viola! Viridis is now available in ParaView!
Update: Nicolás Guarín has converted the color map to the XML format (attached file) that ParaView versions prior to 4.4 can import.
Note that this color map is most appropriate for 2D data. Because the luminance of this color map changes from one end to the other, it is not recommended to color 3D surfaces because luminance changes in color maps interfere with surface shading from lighting.
To design this improved color map, van der Walt and Smith wrote a Python utility called viscm to design color maps with these properties. In addition to providing controls to define a color map in a way that has the desired properties, the utility shows the color map as printed in black and white and approximates how it appears to individuals with different types of color blindness. Screen shots of the utility are shown below.
A description of viscm and how to use it is available here. It provides the ability to export color maps in the form of a Python script. Exported color maps are saved in a file named /tmp/new_cm.py .
I have written a small Python script to convert this file to a JSON file that can be imported into the next release of ParaView. To use this script, first download the attached Python script named viscm2paraview.py. Then, run it with
python viscm2paraview.py /tmp/new_cm.py paraview_cmap.json "My Great Color Map"
Have fun trying viridis and designing new color maps for ParaView!