python - matplotlib/seaborn : first and last row cut in half of heatmap plot

标签 python matplotlib seaborn

当使用 seaborn 绘制热图(以及使用 matplotlib 绘制相关矩阵)时,第一行和最后一行被减半。 当我运行我在网上找到的这个最小代码示例时,也会发生这种情况。

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

data = pd.read_csv('https://raw.githubusercontent.com/resbaz/r-novice-gapminder-files/master/data/gapminder-FiveYearData.csv')
plt.figure(figsize=(10,5))
sns.heatmap(data.corr())
plt.show()

And get this result (I am not allowed to embed images yet) y 轴上的标签位于正确的位置,但行不完整。

几天前,它按预期工作。从那以后,我安装了 texlive-xetex,所以我再次将其删除,但它并没有解决我的问题。

有什么我可能遗漏的想法吗?

最佳答案

不幸的是 ma​​tplotlib 3.1.1 broke seaborn heatmaps ;并且通常带有固定刻度的倒轴。
这在当前的开发版本中已修复;你可能因此

  • 恢复到 matplotlib 3.1.0
  • 使用 matplotlib 3.1.2 或更高版本
  • 手动设置热图限制(ax.set_ylim(bottom, top) # set the ylim to bottom, top)

关于python - matplotlib/seaborn : first and last row cut in half of heatmap plot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57445359/

相关文章:

Python 编码和 json 转储

python - 如何使用 Datetime 和 Python 打印每分钟

python - 如何将seaborn regplot scattplot更改为lineplot?

python - 在不断更新的 matplotlib 中绘图

python - 如何在单个图中为不同的图获得不同的颜色线

python - 使用色调和不同比例轴的 Seaborn(时间序列)箱线图

python - Seaborn 中的黑白箱线图

python - sklearn make_scorer 函数的类型错误

python - 向 Django 管理添加自定义字段

python - 如何在groupby之后绘制数据