pandas Seaborn 热图未显示所有 xticks 和 yticks

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/50754471/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 05:40:00  来源:igfitidea点击:

Seaborn heatmap not displaying all xticks and yticks

pythonpandasmatplotlibseaborn

提问by vaibhavk

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

我有一个形状为 (39, 67) 的Pandas数据框。当我绘制它的seaborn热图时,我在 X 和 Y 轴上没有得到那么多标签。.get_xticklabels()方法也只返回 23 个标签。

Seaborn heatmap for dataframe

数据框的 Seaborn 热图

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

matplotlib也不显示任何标签(仅数字)。

Matpllotlib heatmap

Matplotlib 热图

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

这两个热图都针对同一个数据帧 (39, 67)。

回答by Haran Rajkumar

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

为确保标签可见,您必须像这样设置参数xticklabelsyticklabelsTrue

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

Here'sthe documentation for the heatmapfunction.

这是heatmap函数的文档。