Search code examples
pythonpandasmatplotlibseaborn

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).


Solution

  • 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.