matplotlib/seaborn:热图图的第一行和最后一行被切成两半 [英] matplotlib/seaborn: first and last row cut in half of heatmap plot

查看:158
本文介绍了matplotlib/seaborn:热图图的第一行和最后一行被切成两半的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用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

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆