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.
matplotlib
doesn’t show any labels (only numbers) as well.
Both these heatmaps are for the same dataframe (39, 67).
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.
2
import seaborn as sns
sns.heatmap(dataframe, xticklabels=1, yticklabels=1)
You may also play with figsize=(7, 5)
to adjust the scale.
1
The answers here didnt work for me so I followed the suggestions here.
Try opening a separate matplotlib window and tweak the parameters there,
Python sns heatmap does not fully display x labels
I had the same problem and this solved it:
- axes labels not showing properly:
– after adjusting subplot bottom param: