A thing I immediately liked about seaborn
was that it set the Matplotlib default color palette for images (imshow
, pcolormesh
, contourf
, ...) to a very good one I had not seen before (black-blue-green-brown-pink-purple-white):
plt.contourf(np.random.random((20,20)))
But when I upgraded the package from version 0.21 to 0.3, this default changed to some greyscale:
What is the default color palette from v. 0.2.1 called and how do I get it back?
The default color palette in seaborn v. 0.2.1 is Dave Green's 'cubehelix'
and you can get it back in v. 0.3 via
import seaborn as sns
sns.set(rc={'image.cmap': 'cubehelix'})
A 'brute force' way of finding this out is rolling back to the old version and creating a default plot:
img = plt.contourf(np.random.random((20,20)))
print(img.cmap.name)
In fact, the default in seaborn is defined in this file in the seaborn repo. A look into the Matplotlib sample matplotlibrc file might also help to find the right parameters to adjust.
Just to add to j08lue's answer, the reason it changed is that it's pretty much impossible to choose a single default colormap that is appropriate for all kinds of data, and having a bad color map can cause lots of problems. The hope it that by making the default a grayscale map, it will encourage people to think about their data and choose the right kind of map.
By the way all (most?) matplotlib functions that plot with a colormap will take a cmap
keyword argument, i.e. plt.contourf(x, y, z, cmap="cubehelix")
will work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With