Sid*_*rke 6 python matplotlib seaborn azure-databricks
%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()
Run Code Online (Sandbox Code Playgroud)
此代码不会在天蓝色数据块上提供任何绘图显示,仅显示
<Figure size 1100x900 with 2 Axes>
Run Code Online (Sandbox Code Playgroud)
虽然相同的代码运行良好并且之前显示了正确的图,但不确定这里出了什么问题。即使我尝试这样做,我也会得到相同的输出。
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()
Run Code Online (Sandbox Code Playgroud)
它看起来像是上面的 matplotlib 模块的问题3.3.0
。
要了解确切的原因,我建议您在这里报告:https ://github.com/matplotlib/matplotlib/issues
根据我们最后的测试,您将在上面的 matplotlib 模块中遇到以下错误消息3.3.0
。
如果您已经安装了上面的 matplotlib 模块3.3.0
,我建议您使用下面的 matplotlib 模块3.2.2
。
安装后matplotlib==3.2.2
,我就能够成功显示绘图。
它可能与您的 Databricks 运行时有关 https://docs.databricks.com/notebooks/visualizations/matplotlib.html
作为替代方案,display(plt.show())
如果内联似乎不起作用,请尝试
归档时间: |
|
查看次数: |
5790 次 |
最近记录: |