For diverging values seaborn by default seems to show big numbers in warm tone (orange) and small numbers in cold tone (blue).
If I need to switch color to opposite, to show big numbers in blue and small in orange, how to do so?
I've searched but haven't found a way.
sns.heatmap(flights, center=flights.loc["January", 1955])
You can reverse all of the matplotlib colormaps by appending _r
to the name, i.e., plt.cm.coolwarm
vs plt.cm.coolwarm_r
.
I believe seaborn uses a cubehelix colormap by default.
So you'd do:
from matplotlib import pyplot
import seaborn as sns
colormap = pyplot.cm.cubehelix_r
flights = sns.load_dataset('flights').pivot("month", "year", "passengers")
sns.heatmap(flights, cmap=colormap)
There is no need to build a separate reverse function for heatmap.
Just use cmap = 'magma_r'. The default setting is magma and thus we just append the '_r' for reverse.
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