| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
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.
Sorry, something went wrong.
|
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...). |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
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). |
Sorry, something went wrong.
|
Fair enough, however the point that gcf().canvas.manager is shorter to type and avoids adding API layers for the sake of it remains :) |
Sorry, something went wrong.
|
I have still no clear view what a figure manager does and how the relations between Figure, Canvas and FigureManager are. Is this stuff documented somewhere? From what I found in the code, there's one of each for a figure.
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 Figure. |
Sorry, something went wrong.
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. |
Sorry, something went wrong.
|
According to stackoverflow Q&As the main/most popular use case of plt.get_current_fig_manager() is to set the figure window's position or -size, or raise it to the top like matplotlib.use(<backend>) ... plt.get_current_fig_manager().<backend-dependent way of setting window property> 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? |
Sorry, something went wrong.
|
If you're already doing something backend dependent, you should just do fig.canvas.<whatever> (canvas is a native widget; you can access the parent window with e.g. canvas.parent() or whatnot (depending on the backend)). |
Sorry, something went wrong.
|
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 Canvas sub-class in the backend is multiply inherited from the base 'Widget' class of the GUI toolkit and just provides a way to paint the rendered figure to the screen. The manager classes take care of embedding that widget into a window, adding the toolbar, and any GUI specific set up details. The work in #8777 / #4143 was on attempt at sorting this out. |
Sorry, something went wrong.
|
In the context of what I've understood so far, I'm in favor of leaving get_current_fig_manager() for now. Even though the name is not great, this is the way to access the backend-specific window etc. In contrast, I see gcf().canvas.manager as an implementation detail. In general, why should a canvas know about it's containing window? If anything, I would expect something like gcf().get_manager() since the Figure is the logic representation. From there, you can either get to the drawing surface canvas or to the containing window. Since pyplot is a flat API, it's ok to have a top-level function for this. |
Sorry, something went wrong.
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.
|
To move this forward, I reverted the deprecation and just put in the simpler implementation and docstring. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
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