【问题标题】:Unable to plot graph in google colab无法在 google colab 中绘制图形
【发布时间】:2020-07-02 08:12:06
【问题描述】:

我正在尝试在 google colab 中绘制图表

fig = plt.figure()
plt.title("Weight matrices after model trained")
plt.subplot(1, 3, 1)
plt.title("Trained model Weights")
ax = sns.violinplot(y=h1_w,color='b')
plt.xlabel('Hidden Layer 1')

plt.subplot(1, 3, 2)
plt.title("Trained model Weights")
ax = sns.violinplot(y=h2_w, color='r')
plt.xlabel('Hidden Layer 2 ')

plt.subplot(1, 3, 3)
plt.title("Trained model Weights")
ax = sns.violinplot(y=out_w,color='y')
plt.xlabel('Output Layer ')
plt.show()

该图没有被绘制并且它还显示一个警告 - /usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:8: RuntimeWarning: 超过 20 个数字已打开。通过 pyplot 接口 (matplotlib.pyplot.figure) 创建的图形会一直保留到显式关闭,并且可能会消耗太多内存。 (要控制此警告,请参阅 rcParam figure.max_open_warning)。

如何解决这个问题

【问题讨论】:

标签: python matplotlib google-colaboratory


【解决方案1】:

听起来您无意中启用了不同的 matplotlib 绘图后端(也许您使用 %matplotlib 魔法更改了后端?)

要让您的绘图恢复正常,请重新启动运行时,或在当前运行时运行

%matplotlib inline
plt.close('all')

以后,避免更改绘图后端。

【讨论】:

    猜你喜欢
    • 2020-04-13
    • 1970-01-01
    • 2017-06-30
    • 2019-04-29
    • 2015-10-09
    • 2019-08-14
    • 2013-07-20
    • 1970-01-01
    相关资源
    最近更新 更多