Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Seaborn heatmap not displaying all xticks and yticks

I have a pandas dataframe of shape (39, 67). When I plot it's seaborn heatmap, I don't get as many labels on the X and Y axes. .get_xticklabels() method also returns only 23 labels.

Seaborn heatmap for dataframe

matplotlib doesn't show any labels (only numbers) as well.

Matpllotlib heatmap

Both these heatmaps are for the same dataframe (39, 67).

like image 676
Skywalker Avatar asked Jun 08 '18 06:06

Skywalker


People also ask

How do you annotate a heatmap in Seaborn?

To annotate each cell of a heatmap, we can make annot = True in heatmap() method.

What is FMT in heatmap Seaborn?

The annot only help to add numeric value on python heatmap cell but fmt parameter allows to add string (text) values on the cell. Here, we created a 2D numpy array which contains string values and passes to annot along with that pass a string value “s” to fmt.

What is CMAP in Seaborn?

cmapmatplotlib colormap name or object, or list of colors, optional. The mapping from data values to color space.


1 Answers

To ensure the labels are visible, you have to set the parameters xticklabels, yticklabels to True, like so.

import seaborn as sns  sns.heatmap(dataframe, xticklabels=True, yticklabels=True) 

Here's the documentation for the heatmap function.

like image 114
Haran Rajkumar Avatar answered Sep 25 '22 21:09

Haran Rajkumar