You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
plt.show()
fig.savefig('./result.png',bbox_inches='tight') # save the figure to file
plt.close(fig) # close the figure
OS: Ubuntu 16.04,
The error:
fig.savefig('./result.png',bbox_inches='tight') # save the figure to file
File "/usr/local/lib/python2.7/dist-packages/matplotlib/figure.py", line 1834, in savefig
self.canvas.print_figure(fname, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backend_bases.py", line 2188, in print_figure
self.figure.dpi = dpi
File "/usr/local/lib/python2.7/dist-packages/matplotlib/figure.py", line 436, in _set_dpi
self.set_size_inches(w, h, forward=forward)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/figure.py", line 745, in set_size_inches
manager.resize(int(canvasw), int(canvash))
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 540, in resize
self.canvas._tkcanvas.master.geometry("%dx%d" % (width, height))
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1667, in wm_geometry
return self.tk.call('wm', 'geometry', self._w, newGeometry)
_tkinter.TclError: can't invoke "wm" command: application has been destroyed
The text was updated successfully, but these errors were encountered:
Interestingly this is really a problem of the Tk backend. Using the Qt backend, it is possible to save the figure, even if the window does not exist anymore. The following works:
Install
sudo python -mpip install -U matplotlib
Code
OS: Ubuntu 16.04,
The error:
The text was updated successfully, but these errors were encountered: