MEP23: Multiple Figures per GUI window#
Status#
Discussion
Branches and Pull requests#
Previous work-matplotlib/matplotlib#2465To-delete
Abstract#
Add the possibility to have multiple figures grouped under the sameFigureManager
Detailed description#
Under the current structure, every canvas has its own window.
This is and may continue to be the desired method of operation formost use cases.
Sometimes when there are too many figures open at the same time, it isdesirable to be able to group these under the same window. SeePR #2194.
The proposed solution modifiesFigureManagerBase to contain and manage morethan oneCanvas. Thebackend.multifigure rcParam controls when theMultiFigure behaviour is desired.
Note
It is important to note, that the proposed solution, assumes that theMEP22. isalready in place. This is simply because the actual implementation oftheToolbar makes it pretty hard to switch between canvases.
Implementation#
The first implementation will be done in GTK3 using a Notebook ascanvas container.
FigureManagerBase#
will add the following new methods
add_canvas: To add a canvas to an existingFigureManagerobjectremove_canvas: To remove a canvas from aFigureManagerobject, if it is the last one, it will bedestroyedmove_canvas: To move a canvas from oneFigureManagerto another.set_canvas_title: To change the title associated with a specificcanvas containerget_canvas_title: To get the title associated with a specificcanvas containerget_active_canvas: To get the canvas that is in the foreground andis subject to the gui events. There is noset_active_canvasbecause the active canvas, is defined whenshowis called on aCanvasobject.
new_figure_manager#
To control whichFigureManager will contain the newfigures, an extra optional parameterfiguremanager will be added, thisparameter value will be passed tonew_figure_manager_given_figure.
new_figure_manager_given_figure#
Iffiguremanager parameter is given, this
FigureManagerobject will be used instead of creating anew one.If
rcParams['backend.multifigure']is True: The lastFigureManagerobject will be used instead of creating anew one.
NavigationBase#
Modifies theNavigationBase to keep a list of canvases, directing theactions to the active one.
Backward compatibility#
For theMultiFigure properties to be visible, the user has toactivate them directly settingrcParams['backend.multifigure']=True
It should be backwards compatible for backends that adhere to thecurrentFigureManagerBase structure even if they have notimplemented theMultiFigure magic yet.
Alternatives#
Instead of modifying theFigureManagerBase it could be possible to adda parallel class, that handles the cases wherercParams['backend.multifigure']=True. This will warranty thatthere won't be any problems with custom made backends, but also makesbigger the code, and more things to maintain.