Closed
Description
Install
sudo python -mpip install -U matplotlib
Successfully installed matplotlib-2.1.2
Code
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