Skip to content

new "layout" class #20055

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

Closed
jklymak opened this issue Apr 23, 2021 · 1 comment
Closed

new "layout" class #20055

jklymak opened this issue Apr 23, 2021 · 1 comment
Labels
New feature topic: geometry manager LayoutEngine, Constrained layout, Tight layout
Milestone

Comments

@jklymak
Copy link
Member

jklymak commented Apr 23, 2021

As a follow on to #19892

Currently we have two layout engines, and #19892 proposes to access them with a figure(layout='constrained'/'tight') kwarg and to discourage constrained_layout=True and tight_layout=True.

As a follow up, it would be good to create a new base class class Layout (or FigureLayout) that has subclasses class ConstrainedLayout and class TightLayout but could also have more, and/or user-defined subclasses. This would improve option handling: figure(layout=ConstrainedLayout(wspace=0.2)) instead of passing a hard-to-document dict.

The parent would probably need an __init__ and an execute method, and probably a bunch of setters for the various settings.

This would give us scope to define more layout engines or light wrappers around the existing ones. For instance, a frequently asked one, which is in proplot, is to have an inside-out layout where the axes sizes are fixed and the figure grows or shrinks to accommodate.

This would make the layout manager hot swappable as well, if it only did all its work at draw.

This would also remove state from Figure and Gridspec, though it would add state back to Figure in the fig._layout parameter. To implement, we would add to Figure.draw():

if self._layout is not None:
   self._layout.execute()
@jklymak jklymak added New feature topic: geometry manager LayoutEngine, Constrained layout, Tight layout labels Apr 23, 2021
@story645
Copy link
Member

story645 commented Nov 3, 2022

um is this still open now that https://matplotlib.org/devdocs/api/layout_engine_api.html exists? #20426

@tacaswell tacaswell added this to the v3.6.0 milestone Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New feature topic: geometry manager LayoutEngine, Constrained layout, Tight layout
Projects
None yet
Development

No branches or pull requests

3 participants