8000 Merge pull request #16939 from anntzer/ag · matplotlib/matplotlib@04a3155 · GitHub
[go: up one dir, main page]

Skip to content

Commit 04a3155

Browse files
authored
Merge pull request #16939 from anntzer/ag
Cleanup/tighten axes_grid.
2 parents f2b6c66 + 3b4d7c4 commit 04a3155

File tree

4 files changed

+32
-20
lines changed

4 files changed

+32
-20
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_divider.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,8 @@ def get_vertical_sizes(self, renderer):
6868
return [s.get_size(renderer) for s in self.get_vertical()]
6969

7070
def get_vsize_hsize(self):
71-
72-
from .axes_size import AddList
73-
74-
vsize = AddList(self.get_vertical())
75-
hsize = AddList(self.get_horizontal())
76-
71+
vsize = Size.AddList(self.get_vertical())
72+
hsize = Size.AddList(self.get_horizontal())
7773
return vsize, hsize
7874

7975
@staticmethod

lib/mpl_toolkits/axes_grid1/axes_grid.py

Lines changed: 16 additions & 12 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*.
@@ -335,21 +337,15 @@ def get_axes_locator(self):
335337
return self._divider.get_locator()
336338

337339
def get_vsize_hsize(self):
338-
339340
return self._divider.get_vsize_hsize()
340-
# from axes_size import AddList
341-
342-
# vsize = AddList(self._divider.get_vertical())
343-
# hsize = AddList(self._divider.get_horizontal())
344-
345-
# return vsize, hsize
346341

347342

348343
class ImageGrid(Grid):
349344
# docstring inherited
350345

351346
_defaultCbarAxesClass = CbarAxes
352347

348+
@cbook._delete_parameter("3.3", "add_all")
353349
def __init__(self, fig,
354350
rect,
355351
nrows_ncols,
@@ -388,6 +384,7 @@ def __init__(self, fig,
388384
inches.
389385
add_all : bool, default: True
390386
Whether to add the axes to the figure using `.Figure.add_axes`.
387+
This parameter is deprecated.
391388
share_all : bool, default: False
392389
Whether all axes share their x- and y-axis.
393390
aspect : bool, default: True
@@ -422,11 +419,18 @@ def __init__(self, fig,
422419
self._colorbar_size = cbar_size
423420
# The colorbar axes are created in _init_locators().
424421

425-
super().__init__(
426-
fig, rect, nrows_ncols, ngrids,
427-
direction=direction, axes_pad=axes_pad, add_all=add_all,
428-
share_all=share_all, share_x=True, share_y=True, aspect=aspect,
429-
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)
430434

431435
if add_all:
432436
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)
0