-
Notifications
You must be signed in to change notification settings - Fork 2
Colormaps and Palettes For ParaView and matplotlib pyplot
You've done fantastic science, awesome! Now it's time to make plots and share your results, but before you get carried away, you need to think about colormaps and being colorblind friendly. Around 1 in 12 men and 1 in 200 women are red-green colorblind (deuteranopic), which means it's likely you know someone who is, even if they haven't told you! Of course you want to make sure they can read your plots, right? An excellent resources is ColorCET which provides perceptually uniform and colorblind friendly (both protanopic and deuteranopic) colormaps. You can look at them in the ColorCET gallery and download them.
Note You should never, ever, ever use rainbow/jet. It's incredibly difficult to get a truly perceptually uniform rainbow map and so the "features" that you see in the data when looking at rainbow plots are actually not features of the data but from your eye being more sensitive to certain colors than others. The challenges of rainbow and when it might be okay to use are discussed in this paper.
The default matplotlib color palette (blue, orange, green, ...) is surprisingly terrible. People with a red-green deficiency can hardly see the difference between the orange and the green curves. It's an open issue on the matplotlib repository and this paper by a matplotlib developer suggests a better default. Use a color cycle from that paper, or just skip either the orange or the green from the current default:
# This is the 'deep' color palette from the 'seaborn' package. It's a variation
# of matplotlib's default, but slightly more muted and more colorblind friendly.
# To increase colorblind friendliness further we skip the orange color.
axes.prop_cycle: cycler('color', ['4c72b0', '55a868', 'c44e52', '8172b3',
'937860', 'da8bc3', '8c8c8c', 'ccb974', '64b5cd'])
More color palettes:
- Seaborn also has a "colorblind" palette described here.
- black/orange/blue from https://jfly.uni-koeln.de/color/
To ensure that you always have colorblind-friendly palette when using matplotlib
, there's an easy way to edit the default colormap so you don't have to copy/paste the above block of python code into every one of your scripts. There is a matplotlib
config file located at ~/.config/matplotlib/matplotlibrc
. If this file doesn't exit, you'll need to create it. Then, just copy/paste the above block of code into the ~/.config/matplotlib/matplotlibrc
and your default color map should now be colorblind-friendly!
There are applications that allow you to have your computer display what one with a specific colorblindness would see. Two examples are:
- Color Oracle
- Sim Daltonism
- On recent versions of macOS you can enable a filter in
System Settings-> Accessibility -> Display -> Color Filters
. Just make sure to increase intensity to the maximum.