A Better Default Colormap for Matplotlib | SciPy 2015 | Nathaniel Smith and Stéfan van der Walt
653 2 77486
Complete SciPy 2015 Talk & Tutorial Playlist here: http://ow.ly/PHjEN
By 21 2017-09-20
I think he is talking about the actual false colors being used. I also thought the same thing.
The picture seems to use the "Jet" Matlab colormap, which is pretty bad by many accounts:
By hprotagonist 2017-10-18
here's a great talk about this, in the context of replacing the Jet colormap for matplotlib.
By vanderZwan 2017-10-30
There is the cube-helix approach, but I suspect you're thinking about something else.
The linked talk about the creation of the viridis colour map actually spends a good ten minutes on explaining colour theory, and makes it look very simple in the process.
About ten minutes in it shows the "perceptual colour space" of a typical non-colourblind person. A few minutes later it shows the color spaces for people with various types of colourblindness.
Perhaps one could project one perceptual space into the other in a way that more-or-less preserves the original information, but essentially with more banding?
By anonymous 2017-09-20
As you noted in a comment, your scatter and contour data are not directly related, but you want to display them on the same colormap.
I suggest setting a common colour span that contains both sets of data. Since
obsData refers to the scatter points and
areaData to the contours, I'd set
vmin,vmax = (fun(np.concatenate([obsData,areaData])) for fun in (np.min,np.max))
to determine the span of the collected data set (obviously, to be generalized for multiple input data sets). These can be passed to
contourf to set the limits of the colour mapping:
cs = m.scatter(xs,ys,c=obsData,cmap=plt.cm.viridis,vmin=vmin,vmax=vmax) cs2 = m.contourf(x,y,areaData,cmap=cs.cmap,vmin=vmin,vmax=vmax)
Some manual increase of the span might be in order to obtain a pretty result.
Note that I changed the colormap to
viridis. If you really want to fairly represent your data, this should be your first step.
By anonymous 2017-09-20
There is also a rather "new" way of obtaining an optimal distinctive color palette, also with regards to color blindness and possible black and white conversion with the Viridis color palettes.
To get the palette, simply install the package and use the function
install.packages("viridis") library(viridis) viridis_pal(option = "D")(n) # n = number of colors seeked
With options "A","B","C" and "D" to choose between these palettes:
[EDIT: I'm not allowed to post more than two links because of not enough reputation points, I'll update with more images if I get upvotes...]
For more examples visit the package's vignette. Some of the beautiful examples for it:
There is also an excellent talk explaining the complexity of good palettes on YouTube:
By anonymous 2017-12-11
Given what you've shown of
nn, it looks like the corresponding values are in order.
Therefore, I think you could convert your list to a 2D NumPy array
values = np.array(values).reshape((19, 4978))
and then plot them using
plt.imshow(values). For example,
import numpy as np import matplotlib.pyplot as plt # generate some random values values = np.random.random(19*4978).tolist() # convert the list to a 2D NumPy array values = np.array(values).reshape((19, 4978)) h, w = values.shape fig, ax = plt.subplots() plt.imshow(values) plt.colorbar() plt.yticks(np.arange(h), list('PNIYLKCVFWABCDEFGHI')) ax.set_aspect(w/h) plt.show()
Note that while the default colormap, viridis, is not as colorful as the example
you drew, it does have some very interesting
features. Perhaps the most
important is that the "intensity" of the colors correspond well to a
monotonically increasing scale. Thus you can intuitively "read off" the value
represented by the colors in the plot. The same could not be said of a plot using
jet colormap, or a colormap like the one you proposed where 1--10 is
colored red and 10--20 is colored blue, etc. The reader would be forced to
constantly refer to the colorbar or a legend to check the correspondences between
colors and values.
By anonymous 2018-02-12
I meant [this one](https://www.youtube.com/watch?v=xAoljeRJ3lU). Keep in mind, that viridis is shipped and the default-one in matplotlib 2 (is/was external package at the time of the video).
By anonymous 2018-04-08
Not answer your question but please don't use `rainbow`. See more here https://www.climate-lab-book.ac.uk/2014/end-of-the-rainbow/ & this video https://www.youtube.com/watch?v=xAoljeRJ3lU