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
When using the tkagg backend, a backtrace gets printed, although it doesn't stop and the script finishes normally.
It only seems to happen if you save a figure to a PDF, and then save to a PNG with the bbox_inches="tight" option.
Doing just PNG with tight bbox, or PDF then PNG without tight bbox doesn't output the backtrace.
Code for reproduction
importmatplotlibprint("Backend = ", matplotlib.get_backend())
importmatplotlib.pyplotaspltplt.plot((1,2),(3,4))
print("savefig to PDF")
plt.savefig("fig.pdf")
print("savefig to PNG")
plt.savefig("fig.png", bbox_inches="tight")
print("Done")
Actual outcome
Backend = TkAgg
savefig to PDF
savefig to PNG
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python3.6/tkinter/__init__.py", line 1705, in __call__
return self.func(*args)
File "/usr/lib/python3.6/tkinter/__init__.py", line 749, in callit
func(*args)
File "/home/kirkmatt/tktest/lib/python3.6/site-packages/matplotlib/backends/_backend_tk.py", line 253, in idle_draw
self.draw()
File "/home/kirkmatt/tktest/lib/python3.6/site-packages/matplotlib/backends/backend_tkagg.py", line 9, in draw
super(FigureCanvasTkAgg, self).draw()
File "/home/kirkmatt/tktest/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 407, in draw
self.figure.draw(self.renderer)
File "/home/kirkmatt/tktest/lib/python3.6/site-packages/matplotlib/backend_bases.py", line 1544, in _draw
def _draw(renderer): raise Done(renderer)
matplotlib.backend_bases._get_renderer.<locals>.Done: <matplotlib.backends.backend_agg.RendererAgg object at 0x7f019bb6b5c0>
Done
Expected outcome
The exception is caught somewhere and no backtrace is printed.
Matplotlib version
Operating system: Ubuntu 18.04
Matplotlib version: 3.3.4
Matplotlib backend: TkAgg
Python version: 3.6.9
Other libraries: Tkinter installed using apt install python3-tk, matplotlib installed in a virtualenv with pip
This is possibly related to #18186
There's also a stackoverflow question, although in that case they just save to a png and get the traceback, while if I am only saving to PNG I don't.
The text was updated successfully, but these errors were encountered:
Bug report
When using the tkagg backend, a backtrace gets printed, although it doesn't stop and the script finishes normally.
It only seems to happen if you save a figure to a PDF, and then save to a PNG with the
bbox_inches="tight"
option.Doing just PNG with tight bbox, or PDF then PNG without tight bbox doesn't output the backtrace.
Code for reproduction
Actual outcome
Expected outcome
The exception is caught somewhere and no backtrace is printed.
Matplotlib version
apt install python3-tk
, matplotlib installed in a virtualenv with pipThis is possibly related to #18186
There's also a stackoverflow question, although in that case they just save to a png and get the traceback, while if I am only saving to PNG I don't.
The text was updated successfully, but these errors were encountered: