Matplotlib不在数据块上打印任何绘图?

2024-09-25 10:19:26 发布

您现在位置:Python中文网/ 问答频道 /正文

%matplotlib inline
corr = df.corr()
f, ax = plt.subplots(figsize=(11, 9))
ax = sns.heatmap(
    corr, 
    vmin=-1, vmax=1, center=0,
    cmap=sns.diverging_palette(20, 220, n=500),
    linewidths=.50, 
    cbar_kws={"shrink": .7},
    square=True
)

ax.set_xticklabels(
    ax.get_xticklabels(),
    rotation=45,
    horizontalalignment='right'
);
plt.show()

此代码不在azure数据块上显示任何绘图,仅显示

<Figure size 1100x900 with 2 Axes>

虽然相同的代码运行良好,并在前面显示了一个corr图,但不确定这里出了什么问题。 即使我尝试这个,我也会得到相同的输出

mask = np.triu(np.ones_like(corr, dtype=bool))

f, ax = plt.subplots(figsize=(11, 9))

cmap = sns.diverging_palette(20, 220, as_cmap=True)

sns.heatmap(corr, mask=mask, cmap=cmap, vmax=0.3, center=0,
            square=True, linewidths=.1, cbar_kws={"shrink": .7})
plt.show()

Tags: truepltmaskaxcmapcentersnsheatmap
1条回答
网友
1楼 · 发布于 2024-09-25 10:19:26

上面的matplotlib模块似乎有问题

To know the exact reason, I would suggest you to report here: https://github.com/matplotlib/matplotlib/issues

根据我们的测试,您将在上面的matplotlib模块中遇到以下错误消息3.3.0

enter image description here

如果您已经在3.3.0上面安装了matplotlib模块,我建议您使用3.2.2下面的matplotlib模块

enter image description here

一旦您安装了matplotlib==3.2.2,我就能够成功地显示绘图

enter image description here

相关问题 更多 >