Ash*_*mar 1 python matplotlib google-colaboratory
我正在尝试在 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()
Run Code Online (Sandbox Code Playgroud)
该图未绘制,并且还显示警告 - /usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:8: RuntimeWarning: 已打开 20 多个图形。通过 pyplot 接口 ( matplotlib.pyplot.figure)创建的图会保留直到明确关闭,并且可能会消耗太多内存。(要控制此警告,请参阅 rcParam figure.max_open_warning)。
如何解决这个问题
听起来您无意中启用了不同的 matplotlib 绘图后端(也许您使用%matplotlib魔法更改了后端?)
要使绘图恢复正常,请重新启动运行时,或在当前运行时运行
%matplotlib inline
plt.close('all')
Run Code Online (Sandbox Code Playgroud)
并且在将来,避免更改绘图后端。