Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Open
Labels
Milestone
Description
Bug report
Bug summary
The behavior of Tk backend in interactive mode has changed. My code depends on the old behavior and does not work with matplotlib 3.4.
Code for reproduction
importtimeimportnumpyasnpimportmatplotlibasmplfrommatplotlibimportpyplotaspltdeftest_heatmap_draw():mpl.use("TkAgg")plt.ion()DATA_SHAPE=10,10fig=plt.figure()ax=fig.add_subplot()img=ax.imshow(np.zeros(DATA_SHAPE),vmin=-1,vmax=1)for_inrange(10):img.set_data(np.random.uniform(-1,1,DATA_SHAPE))fig.canvas.draw()time.sleep(0.1)if__name__=="__main__":test_heatmap_draw()
Actual outcome
No windows are shown with matplotlib >= 3.4.
I guess that#17789 is the trigger. Insertingself._master.update_idletasks
worked, like:
classFigureCanvasTkAgg(FigureCanvasAgg,FigureCanvasTk):defdraw(self):super().draw()self.blit()self._master.update_idletasks()
Expected outcome
The heatmap is interactively updated with matplotlib 3.3.4.
- Is this change intended? Then I want to know a proper way to write this kind of app. I know that
plt.pause(0.1)
works, but actually don't want to pause in my actual use case.- Also, could I help enhancing the document around this? E.g., inhttps://matplotlib.org/stable/users/interactive.html .
- If this is not intended, how could I fix backends in a reasonable way?
BTW, thank you for encouraging me ontwitter.