-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ENH]: Reusing the same GUI window for showing multiple figures #28259
Comments
Have you considered using jupyter notebooks? They are well suited for
While a „persistent window mode“ would make window management more usable, the iterative editing in a shell (and I‘m assuming you’re working from there) is still more cumbersome than in a notebook. - I‘m sceptical on investing in a feature to improve a workflow that’ll still be inferior to an alternative. But maybe I‘m not fully understanding how you want to work. Please describe your intended workflow in more detail and also the desired new API/commands with a concrete example and expected effect (including when exactly you expect the old figure to end life and the new figure be connected to the gui window). |
I think all of the API you need from Matplotlib exist fig = plt.gcf() # get the currently active figure
fig.clf() # clear the figure to start fresh
ax_arr = fig.subplots(2, 2) If you do the above on your function it will always reuse the most recently used figure (or create it if it has to) fig = plt.figure('some name') # create a figure by name
fig2 = plt.figure('some name') # get it back
assert fig is fig2 Using the above you can give a name to your figure so everytime the function run it works on the same window (creating it if it has to) def some_function(a, b, c, *, fig=None):
if fig is None:
fig = plt.figure()
... In your function you should make it possible to pass in a |
@tacaswell Thank you! That's precisely it. I feel a bit stupid now that I didn't think of |
Problem
Often I find myself hacking on a function that creates a new Figure object, evaluating it over and other.
It would be very nice to have the option of reusing the same GUI window rather than closing the old one and opening a new one all the time.
Proposed solution
Currently, I'm using decorators that close the last created figure. Maybe one could add a method to the pyplot API that instructs it to re-use the currently open interactive GUI window. A little like what can be emulated with plt.cla() and plt.clf()...
The text was updated successfully, but these errors were encountered: