-by Krishna Rao
Information is not knowledge.
Information can be converted into knowledge if patterns underlying the information are well understood. In today’s day and age of fast-paced advances in science and technology, one of the key information sources is data. It is hardly surprising then that we produce a lot of it- about 2.5 quintillion bytes every day.
One of the most powerful ways to make sense of scientific data (and thus transform it into knowledge) is by plotting it.
Want to know if human weight is related to height? Plot it!
Want to know whether the expansion of the universe is accelerating? Plot it!
Want to know how hot it gets the farther you go from the equator? Plot it … err carefully!
Although visualizations can be powerful to consume data quickly and derive insights, they can also be harmful if not done right.
In this article we will learn:
Look at the above figure of sea surface temperature (SST) and try to summarize it in one sentence. When I showed the above chart to 10 of my friends, seven of them responded with some version of the following, “The temperature decreases as we go away from the equator, with a sudden transition at about 30 degrees north or south” (italics are mine). The reason my friends thought there was a sudden change in temperature was that colors with high luminance (like yellow) stand out in our eyes. In other words, the colormap used above creates artificial contrasts where none exists. The same data in a better colormap (example with “viridis” is shown below) shows that there is no such sudden transition.
We could excuse this if it was a one-off case. Unfortunately, the scientific literature is full of such maps using bad, perceptually non-uniform colormaps like “jet”, “rainbow”, “spectral”, “gist”, etc. To add to the harm, many of these colormaps are also not friendly to colorblind people!
In 2015, many people noticed this phenomenon and nudged their respective communities in R, Python, Matlab, etc. to change their default colormaps to be perceptually uniform so as to not introduce any artificial gradients in luminance. For more information about the update, check out the launch of the new default colormaps in matplotlib in Python. I encourage everyone to use the perceptually-uniform colormaps available to them (they can be found here for Python and R). But that still leaves us with the poorly-created maps from the pre-2015 era. If left unfixed, they can be difficult to cite in posters or presentations. To date, they continue to appear in top conferences, journals, and reports. How can we continue to use the knowledge from the “jet” era, but avoid the pitfalls associated with interpreting them?
fixthejet is a python package that can transform an image (.jpg/.png) from “jet” colormap to any other colormap based on user input. The script selectively changes jet colors only. All other colors in the image remain unchanged. Thus, the background and text of images are left unchanged (provided, they are visibly different than colors in "jet"). Since the package requires only an image file, the time and effort required to obtain the raw data underlying the image is avoided.
Changing the colormaps of poorly-made images by others is now as simple as entering this in the terminal:
python fixthejet.py --input <input file> --output <output file>
Here are two examples showing how the package can transform images from “jet” colormap to perceptually-uniform colormaps.
python fixthejet.py --input .\images\cube.png --output .\images\cube_plasma.png --colormap plasma
python fixthejet.py --input .\images\cone.jpg --output .\images\cone_inferno.jpg --colormap inferno
Use --colormap <output colormap> to control the colormap of outfile. Default is "viridis". Only Matplotlib colormaps are supported.
Interested in using fixthejet? Here are the downloading instructions.
Using bad colormaps like "jet" can lead to artificial gradients, which in some cases, can lead to false inferences. Be kind to your audience and avoid non-uniform colormaps like "jet", "rainbow", "spectral", etc.
If you are making your own map, do not use “jet” or other perceptually non-uniform colormaps
If you want to use someone else’s poorly made figure in your presentation, use fixthejet python package to change the colormap and remove any artificially-created patterns