Dear Maintainer,
I have experienced intermittent problems with the default TkAgg backend for
python3-matplotlib since I upgraded from buster to bullseye. The problems
go away if you start a program with
import matplotlib as mp
mp.use("Qt5Agg")
to switch to a different backend. I include an example below which triggers
a slew of Tk error messages, although the output seems correct. Sometimes
there are problems with the output as well; I am still trying to produce an
example that produces wrong graphical output but which is simple enough to
submit in a bug report. It appears that to trigger the error messages you
need to
(*) Use plt.ion() as you would in ipython3 (rather than using plt.show() as
you would from the shell).
(*) Use plt.savefig(bbox_inches="tight")
Best wishes
Hugh Pumphrey
##########Begin######example####################
import matplotlib as mp
## Uncomment next line to switch to working Qt5Agg backend
## Default is the same as mp.use("TkAgg")
##mp.use("Qt5Agg")
##mp.use("TkAgg")
import numpy as np
import matplotlib.pyplot as plt
plt.ion()
## plt.close("all")
fig=plt.figure(figsize=(8,4))
plt.clf()
ax=plt.axes()
x=np.linspace(0,10,11)
ax.plot(x,x*x,"ro")
ax.text(5,30,"Test text",fontsize=18)
## plt.show()
## Tk errors get emitted only when you do a plt.savefig()
## with the bbox_inches="tight" option. It is a bit mysterious exactly
## how it is triggered. Use of plt.ion() seems needed.
plt.savefig("test.png",bbox_inches="tight")
#####end######example#########################