-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Simplify get_current_fig_manager(). #14085
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_current_figure_manager()
is definitively nothing that should be in the user-facing pyplot API.
Not sure is should stay as a private function or maybe as a method of Figure
. The deep nesting gcf().canvas.manager
feels like there's a proper interface layer missing, but I'm not enough into the manager business to judge that.
I think the number of cases where a end user needs to access a manager is rare enough that being one additional layer deep is not something to worry about (basically, it's (mostly) only relevant when they're using pyplot to create the figures, but then still want to do stuff with the underlying toolkit widget...). |
I was more thinking along the lines: If people use the high-level pyplot API, the shouldn't have to do anything with managers. That mentioned additional layer would more be for experts and for having an internal clean structure. |
Accessing the manager can be very useful for setting custom window titles after the fact (which in turn controls how they show up in the task bar). |
Fair enough, however the point that gcf().canvas.manager is shorter to type and avoids adding API layers for the sake of it remains :) |
I have still no clear view what a figure manager does and how the relations between
Attempt do define what the classes are for: Depending on what the manager is actually meant for, it makes sense or not to keep it accessible directly through pyplot. I could also imagine that it makes sense to access the manager through the |
Withdrawing my approval for now as I've realized I don't really understand this stuff.
Very briefly, the FigureManager is what holds onto the native qt/gtk/wx/tk window that pyplot sets up to hold the canvas. |
According to stackoverflow Q&As the main/most popular use case of
Answers of this type have an accumulated number of some >50 votes. This seems like a clear sign that there is a lot of code in the wild that would suffer from the deprecation. In that sense, what is the benefit of removing it? |
If you're already doing something backend dependent, you should just do |
I am 👍 on the internal changes, 👎 on deprecating it (there is no maintenance burden on it and as @ImportanceOfBeingErnest there would be a real user-cost to this change), 👍 for changing the docstring to saying "use this other thing instead". @timhoffm In most (all?) cases the The work in #8777 / #4143 was on attempt at sorting this out. |
In the context of what I've understood so far, I'm in favor of leaving Even though the name is not great, this is the way to access the backend-specific window etc. In contrast, I see |
86fe348
to
d496e77
Compare
Also make ``plt.subplot_tool`` work even for non-pyplot-managed figures -- there's no reason not to, it's just that such figures cannot be made the "current" pyplot figure.
d496e77
to
e615fe5
Compare
To move this forward, I reverted the deprecation and just put in the simpler implementation and docstring. |
It's longer to type(!) than its actual implementation
(
gcf().canvas.manager
), and mixes the pyplot and the OO-interfaces.Also make
plt.subplot_tool
work even for non-pyplot-managed figures-- there's no reason not to, it's just that such figures cannot be made
the "current" pyplot figure.
PR Summary
PR Checklist