matplotlib/seaborn:第一行和最后一行切成热图的一半 [英] matplotlib/seaborn: first and last row cut in half of heatmap plot
问题描述
使用 seaborn(以及使用 matplotlib 绘制相关矩阵)绘制热图时,第一行和最后一行被切成两半.当我运行这个我在网上找到的最小代码示例时,也会发生这种情况.
When plotting heatmaps with seaborn (and correlation matrices with matplotlib) the first and the last row is cut in halve. This happens also when I run this minimal code example which I found online.
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()
y 轴上的标签位于正确的位置,但行不完全在那里.
The labels at the y axis are on the correct spot, but the rows aren't completely there.
几天前,它按预期工作.从那以后,我安装了 texlive-xetex,所以我再次将其删除,但并没有解决我的问题.
A few days ago, it work as intended. Since then, I installed texlive-xetex so I removed it again but it didn't solve my problem.
有什么我可能遗漏的想法吗?
Any ideas what I could be missing?
推荐答案
不幸的是 matplotlib 3.1.1 破坏了seaborn热图;并且通常带有固定刻度的倒轴.
这在当前的开发版本中已修复;你可能因此
Unfortunately matplotlib 3.1.1 broke seaborn heatmaps; and in general inverted axes with fixed ticks.
This is fixed in the current development version; you may hence
- 恢复到 matplotlib 3.1.0
- 使用 matplotlib 3.1.2 或更高版本
- 手动设置热图限制(
ax.set_ylim(bottom, top) # set the ylim to bottom, top
)
这篇关于matplotlib/seaborn:第一行和最后一行切成热图的一半的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!