python - Matplotlib 不在 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()
此代码不会在 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()
解决方案
上面的 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
后,我就可以成功显示该图了。
推荐阅读
- python - Python Instagram 机器人
- c# - C# WINFORMS 控件字体在运行时不平滑
- c - 数组类型“some_typedef_name”不可分配
- reactjs - 身份验证后的预渲染路由
- php - Docker、nginx 和 Grav 的权限问题
- c# - 使用 ctrl+tab 添加到 tabcontrol 的每隔一个 tabpage 不会触发事件
- javascript - HTML 和 Javascript 搜索结果分页 - 限制显示的结果页面数量
- c# - 如何在 Gridview 中获取第一行和最后一行?
- gitlab-ci - 当我运行 cypress 作为 npm run cypress run build 失败
- angular - “ng generate universal”和“ng add @nguniversal/express-engine”有什么区别?