Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3b4d7c4

Browse files
committed
Deprecate add_all parameter.
I'm not really sure there's a use case for not adding axes to the parent figure (it was never used in the history of the library), and in any case axes can always be removed with `ax.remove()`.
1 parent 80d799c commit 3b4d7c4

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

doc/api/next_api_changes/deprecations.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,3 +402,10 @@ The qt4agg and qt4cairo backends are deprecated.
402402
``RendererWx.get_gc``
403403
~~~~~~~~~~~~~~~~~~~~~
404404
This method is deprecated. Access the ``gc`` attribute directly instead.
405+
406+
*add_all* parameter in ``axes_grid``
407+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
408+
The *add_all* parameter of `.axes_grid1.axes_grid.Grid`,
409+
`.axes_grid1.axes_grid.ImageGrid`, `.axes_grid1.axes_rgb.make_rgb_axes` and
410+
`.axes_grid1.axes_rgb.RGBAxes` is deprecated. Axes are now always added to the
411+
parent figure, though they can be later removed with ``ax.remove()``.

lib/mpl_toolkits/axes_grid1/axes_grid.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class Grid:
9393

9494
_defaultAxesClass = Axes
9595

96+
@cbook._delete_parameter("3.3", "add_all")
9697
def __init__(self, fig,
9798
rect,
9899
nrows_ncols,
@@ -128,6 +129,7 @@ def __init__(self, fig,
128129
inches.
129130
add_all : bool, default: True
130131
Whether to add the axes to the figure using `.Figure.add_axes`.
132+
This parameter is deprecated.
131133
share_all : bool, default: False
132134
Whether all axes share their x- and y-axis. Overrides *share_x*
133135
and *share_y*.
@@ -343,6 +345,7 @@ class ImageGrid(Grid):
343345

344346
_defaultCbarAxesClass = CbarAxes
345347

348+
@cbook._delete_parameter("3.3", "add_all")
346349
def __init__(self, fig,
347350
rect,
348351
nrows_ncols,
@@ -381,6 +384,7 @@ def __init__(self, fig,
381384
inches.
382385
add_all : bool, default: True
383386
Whether to add the axes to the figure using `.Figure.add_axes`.
387+
This parameter is deprecated.
384388
share_all : bool, default: False
385389
Whether all axes share their x- and y-axis.
386390
aspect : bool, default: True
@@ -415,11 +419,18 @@ def __init__(self, fig,
415419
self._colorbar_size = cbar_size
416420
# The colorbar axes are created in _init_locators().
417421

418-
super().__init__(
419-
fig, rect, nrows_ncols, ngrids,
420-
direction=direction, axes_pad=axes_pad, add_all=add_all,
421-
share_all=share_all, share_x=True, share_y=True, aspect=aspect,
422-
label_mode=label_mode, axes_class=axes_class)
422+
if add_all:
423+
super().__init__(
424+
fig, rect, nrows_ncols, ngrids,
425+
direction=direction, axes_pad=axes_pad,
426+
share_all=share_all, share_x=True, share_y=True, aspect=aspect,
427+
label_mode=label_mode, axes_class=axes_class)
428+
else: # Only show deprecation in that case.
429+
super().__init__(
430+
fig, rect, nrows_ncols, ngrids,
431+
direction=direction, axes_pad=axes_pad, add_all=add_all,
432+
share_all=share_all, share_x=True, share_y=True, aspect=aspect,
433+
label_mode=label_mode, axes_class=axes_class)
423434

424435
if add_all:
425436
for ax in self.cbar_axes:

lib/mpl_toolkits/axes_grid1/axes_rgb.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from .mpl_axes import Axes
66

77

8+
@cbook._delete_parameter("3.3", "add_all")
89
def make_rgb_axes(ax, pad=0.01, axes_class=None, add_all=True, **kwargs):
910
"""
1011
Parameters
@@ -89,14 +90,16 @@ class RGBAxes:
8990

9091
_defaultAxesClass = Axes
9192

93+
@cbook._delete_parameter("3.3", "add_all")
9294
def __init__(self, *args, pad=0, add_all=True, **kwargs):
9395
"""
9496
Parameters
9597
----------
9698
pad : float, default: 0
9799
fraction of the axes height to put as padding.
98100
add_all : bool, default: True
99-
Whether to add the {rgb, r, g, b} axes to the figure
101+
Whether to add the {rgb, r, g, b} axes to the figure.
102+
This parameter is deprecated.
100103
axes_class : matplotlib.axes.Axes
101104
102105
*args
@@ -108,8 +111,10 @@ def __init__(self, *args, pad=0, add_all=True, **kwargs):
108111
self.RGB = ax = axes_class(*args, **kwargs)
109112
if add_all:
110113
ax.get_figure().add_axes(ax)
114+
else:
115+
kwargs["add_all"] = add_all # only show deprecation in that case
111116
self.R, self.G, self.B = make_rgb_axes(
112-
ax, pad=pad, axes_class=axes_class, add_all=add_all, **kwargs)
117+
ax, pad=pad, axes_class=axes_class, **kwargs)
113118
self._config_axes()
114119

115120
def _config_axes(self, line_color='w', marker_edge_color='w'):

0 commit comments

Comments
 (0)