3
3
4
4
Figures have a ``layout_engine`` property that holds a subclass of
5
5
`~.LayoutEngine` defined here (or *None* for no layout). At draw time
6
- ``figure.get_layout_engine().execute()`` is called, the goal of which is usually
7
- to rearrange Axes on the figure to produce a pleasing layout. This is like a
8
- ``draw`` callback, however when printing we disable the layout engine for the
9
- final draw and it is useful to know the layout engine while the figure is being
10
- created, in particular to deal with colorbars.
6
+ ``figure.get_layout_engine().execute()`` is called, the goal of which is
7
+ usually to rearrange Axes on the figure to produce a pleasing layout. This is
8
+ like a ``draw`` callback, however when printing we disable the layout engine
9
+ for the final draw and it is useful to know the layout engine while the figure
10
+ is being created, in particular to deal with colorbars.
11
11
12
12
Matplotlib supplies two layout engines, `.TightLayoutEngine` and
13
- `.ConstrainedLayoutEngine`. Third parties can create their own layout engine by
14
- subclassing `.LayoutEngine`.
13
+ `.ConstrainedLayoutEngine`. Third parties can create their own layout engine
14
+ by subclassing `.LayoutEngine`.
15
15
"""
16
16
17
17
from contextlib import nullcontext
@@ -39,7 +39,7 @@ class LayoutEngine:
39
39
at draw time by `~.figure.Figure.draw`, providing a special draw-time hook.
40
40
41
41
Currently, there are two properties of ``LayoutEngine`` classes that are
42
- consulted while manipulating the figure. ``engine.get_colorbar_gridspec ``
42
+ consulted while manipulating the figure. ``engine.colorbar_gridspec ``
43
43
tells `.Figure.colorbar` whether to make the axes using the gridspec
44
44
method (see `.colorbar.make_axes_gridspec`) or not
45
45
(see `.colorbar.make_axes`); `.ConstrainedLayoutEngine` sets this to
@@ -58,14 +58,16 @@ def __init__(self):
58
58
def set (self , ** kwargs ):
59
59
raise NotImplementedError
60
60
61
- def get_colorbar_gridspec (self ):
61
+ @property
62
+ def colorbar_gridspec (self ):
62
63
"""
63
64
Return a boolean if the layout engine creates colorbars using a
64
65
gridspec.
65
66
"""
66
67
return self ._colorbar_gridspec
67
68
68
- def get_adjust_compatible (self ):
69
+ @property
70
+ def adjust_compatible (self ):
69
71
"""
70
72
Return a boolean if the layout engine is compatible with
71
73
`~.Figure.subplots_adjust`.
@@ -163,6 +165,7 @@ def set(self, *, pad=None, w_pad=None, h_pad=None, rect=None):
163
165
if locals ()[td ] is not None :
164
166
self ._params [td ] = locals ()[td ]
165
167
168
+
166
169
class ConstrainedLayoutEngine (LayoutEngine ):
167
170
"""
168
171
Implements the ``constrained_layout`` geometry management. See
0 commit comments