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
{{ message }}
Repository navigation
Windows are not shown with Tk + interactive mode, from matplotlib 3.4 #19935
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.
My opinion is that this is the intended behavior. It is harmful to call update_idletasks or update in TCL library code for the reasons mentioned in that issue. However, client code should be free to use it. In this case the appropriate api, since you are driving your own event loop, is figure.canvas.flush_events which just calls update but in a backend-agnostic way.
Updating the docs would be very nice, I'll help where I can!
If in interactive mode:
- newly created figures will be displayed immediately
- figures will automatically redraw when elements are changed
- pyplot.show() displays the figures and immediately returns
However, I guess that we need flush_events or some blocking functions to render images. Are these descriptions are simply outdated? Or, do I miss something?
Any help is greatly appricated.
A little farther down in that page there are some exceptions to those bullet points:
The GUI event loop being integrated with your command prompt and the figures being in interactive mode are independent of each other. If you use pyplot.ion but have not arranged for the event loop integration, your figures will appear but will not be interactive while the prompt is waiting for input.
and
Using figure.Figure.show it is possible to display a figure on the screen without starting the event loop and without being in interactive mode. This may work (depending on the GUI toolkit) but will likely result in a non-responsive figure.
I think it is a subtle and possibly confusing point that interactive mode is not interactive unless you are working in a command prompt with event loop integration. That is, if you run a script with matplotlib code such as what you posted above, you will have a different result of interactivity compared with typing each command at the REPL.In my mind, the thing you need to do to get interactivity is pump GUI events, and plt.ion just configures some of the pyplot API to "work better" at the REPL.
Perhaps bringing these facts forward in doc/users/interactive.rst before the bullet points would help?
I think it is a subtle and possibly confusing point that interactive mode is not interactive unless you are working in a command prompt with event loop integration.
Right, I didn't actually understand that point.
Perhaps bringing these facts forward in doc/users/interactive.rst before the bullet points would help?
Thank you for the pointer. I would like also to mention that some backends behaved inconsistently on this point, but they are fixed.
Activity
richardsheridan commentedon Apr 11, 2021
My opinion is that this is the intended behavior. It is harmful to call
update_idletasksorupdatein TCL library code for the reasons mentioned in that issue. However, client code should be free to use it. In this case the appropriate api, since you are driving your own event loop, isfigure.canvas.flush_eventswhich just callsupdatebut in a backend-agnostic way.Updating the docs would be very nice, I'll help where I can!
kngwyu commentedon Apr 12, 2021
@richardjgowers
Thank you for your help! That makes sense.
For documents, I think the Explicitly spinning the Event Loop is enough good, but I feel the more entry-level description of interactive mode is somewhat confusing.
It says that:
However, I guess that we need
flush_eventsor some blocking functions to render images. Are these descriptions are simply outdated? Or, do I miss something?Any help is greatly appricated.
richardsheridan commentedon Apr 12, 2021
A little farther down in that page there are some exceptions to those bullet points:
and
I think it is a subtle and possibly confusing point that interactive mode is not interactive unless you are working in a command prompt with event loop integration. That is, if you run a script with matplotlib code such as what you posted above, you will have a different result of interactivity compared with typing each command at the REPL.In my mind, the thing you need to do to get interactivity is pump GUI events, and
plt.ionjust configures some of the pyplot API to "work better" at the REPL.Perhaps bringing these facts forward in
doc/users/interactive.rstbefore the bullet points would help?QuLogic commentedon Apr 13, 2021
You should replace this with
plt.pause(0.1)to run the main loop.kngwyu commentedon Apr 13, 2021
Right, I didn't actually understand that point.
Thank you for the pointer. I would like also to mention that some backends behaved inconsistently on this point, but they are fixed.