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 annotate each cell of a heatmap, we can make annot = True in heatmap() method.
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.
cmapmatplotlib colormap name or object, or list of colors, optional. The mapping from data values to color space.
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.
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