Skip to content

Commit 28621ee

Browse files
committed
FIX: make properties
1 parent f7b2485 commit 28621ee

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

lib/matplotlib/figure.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ def colorbar(
11421142
"to colorbar().")
11431143

11441144
if (self.get_layout_engine() is not None and
1145-
not self.get_layout_engine().get_colorbar_gridspec()):
1145+
not self.get_layout_engine().colorbar_gridspec):
11461146
use_gridspec = False
11471147
# Store the value of gca so that we can set it back later on.
11481148
if cax is None:
@@ -1197,7 +1197,7 @@ def subplots_adjust(self, left=None, bottom=None, right=None, top=None,
11971197
as a fraction of the average Axes height.
11981198
"""
11991199
if (self.get_layout_engine() is not None and
1200-
not self.get_layout_engine().get_adjust_compatible()):
1200+
not self.get_layout_engine().adjust_compatible):
12011201
_api.warn_external(
12021202
"This figure was using a layout engine that is "
12031203
"incompatible with subplots_adjust and/or tight_layout; "

lib/matplotlib/layout_engine.py

+13-10
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
44
Figures have a ``layout_engine`` property that holds a subclass of
55
`~.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.
1111
1212
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`.
1515
"""
1616

1717
from contextlib import nullcontext
@@ -39,7 +39,7 @@ class LayoutEngine:
3939
at draw time by `~.figure.Figure.draw`, providing a special draw-time hook.
4040
4141
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``
4343
tells `.Figure.colorbar` whether to make the axes using the gridspec
4444
method (see `.colorbar.make_axes_gridspec`) or not
4545
(see `.colorbar.make_axes`); `.ConstrainedLayoutEngine` sets this to
@@ -58,14 +58,16 @@ def __init__(self):
5858
def set(self, **kwargs):
5959
raise NotImplementedError
6060

61-
def get_colorbar_gridspec(self):
61+
@property
62+
def colorbar_gridspec(self):
6263
"""
6364
Return a boolean if the layout engine creates colorbars using a
6465
gridspec.
6566
"""
6667
return self._colorbar_gridspec
6768

68-
def get_adjust_compatible(self):
69+
@property
70+
def adjust_compatible(self):
6971
"""
7072
Return a boolean if the layout engine is compatible with
7173
`~.Figure.subplots_adjust`.
@@ -163,6 +165,7 @@ def set(self, *, pad=None, w_pad=None, h_pad=None, rect=None):
163165
if locals()[td] is not None:
164166
self._params[td] = locals()[td]
165167

168+
166169
class ConstrainedLayoutEngine(LayoutEngine):
167170
"""
168171
Implements the ``constrained_layout`` geometry management. See

0 commit comments

Comments
 (0)