问题描述
我正在Jupyter实验室工作,并试图保存该数字。函数savefig()恰好在show()之前调用,该图在笔记本中很好地显示,但是保存的pdf为空白。
原始代码很长,基本上就像:
ylim = 8
ax = plt.subplot(321)
ax.plot(list(range(80)),np.random.randn(80),color='purple',alpha=0.5)
ax.set_xlim([0,79])
ax.set_ylim([-ylim,ylim])
plt.gca().xaxis.set_major_locator(plt.NullLocator())
plt.gca().yaxis.set_major_locator(plt.NullLocator())
ax = plt.subplot(323)
ax.axvspan(59,79,facecolor='pink',alpha=0.5)
ax.plot(list(range(80)),color='g',ylim])
plt.gca().xaxis.set_major_locator(plt.NullLocator())
plt.gca().yaxis.set_major_locator(plt.NullLocator())
ax = plt.subplot(325)
ax.axvspan(59,alpha=0.5)
ax.plot(list(range(60)),color='b',ylim])
plt.gca().xaxis.set_major_locator(plt.NullLocator())
plt.gca().yaxis.set_major_locator(plt.NullLocator())
ax = plt.subplot(122)
ax.imshow(image)
plt.gca().set_axis_off()
plt.gca().xaxis.set_major_locator(plt.NullLocator())
plt.gca().yaxis.set_major_locator(plt.NullLocator())
plt.subplots_adjust(top = 1,bottom = 0,right = 3,left = 1,hspace = 0,wspace = 0)
plt.margins(0,0)
plt.savefig('figure.pdf',pad_inches=0,dpi=500,transparent=True)
plt.show()
But well shown in the notebook
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)