Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

seaborn heatmap y-axis reverse order

Have a look at this heatmap found in the seaborn heatmap documentation.

Right now the y-axis starts with 9 at the bottom, and ends with 0 on top. Is there a way to turn this around, i.e. start with 0 at bottom and end with 9 at the top?

like image 440
john kals Avatar asked Dec 11 '15 20:12

john kals


People also ask

How do you reverse axis in Seaborn?

The value of Y-axis in a seaborn heatmap is reversed when home icon or H button is pushed.

How do I get rid of Xticks in Seaborn?

Use tick_params() for changing the appearance of ticks and tick labels. Use left=false and bottom=false to remove the tick marks.

What is FMT in Seaborn heatmap?

heatmap() fmt parameter – add text on each cell. fmt: Pass value as a string, optional.


1 Answers

Looks like ax.invert_yaxis() solves it.

Following the example from which you got the figure:

import numpy as np; np.random.seed(0) import seaborn as sns; sns.set() uniform_data = np.random.rand(10, 12) ax = sns.heatmap(uniform_data) ax.invert_yaxis() 

Gives: enter image description here

like image 149
user3412205 Avatar answered Sep 22 '22 14:09

user3412205