After upgrading to 24.04 I ran into a problem resulting in this error: ImportError: Cannot load backend 'TkAgg' which requires the 'tk' interactive framework, as 'gtk3' is currently running.
After testing with various ways of import of mathplotlib I ended up with this which work for my program:
import matplotlib.pyplot as plt
import matplotlib as mpl print ("matplot-versjon: ", mpl.version)
tekst = mpl.get_backend() print("Backend = ", tekst)
from matplotlib import image as mpimg
plt.switch_backend('TkAgg') # This line seems to be the one that made the difference.
(I seem to have no control over the formatting of this text. Everything is there, but linefeeds are missing here and there.