Description
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()