Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a87b3f3

Browse filesBrowse files
authored
Merge pull request #20052 from anntzer/mt33
Remove axes_grid/axisartist APIs deprecated in Matplotlib 3.3.
2 parents 5120b19 + b0023f5 commit a87b3f3
Copy full SHA for a87b3f3

File tree

Expand file treeCollapse file tree

8 files changed

+52
-140
lines changed
Filter options
Expand file treeCollapse file tree

8 files changed

+52
-140
lines changed
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Removal of ``axes_grid``/``axisartist`` APIs deprecated in Matplotlib 3.3
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
The following deprecated APIs have been removed:
4+
5+
- ``CbarAxesBase.cbid`` and ``CbarAxesBase.locator`` (use
6+
``mappable.colorbar_cid`` and ``colorbar.locator`` instead),
7+
- the ``add_all`` parameter to ``axes_grid.Grid``, ``axes_grid.ImageGrid``,
8+
``axes_rgb.make_rgb_axes``, ``axes_rgb.RGBAxes`` (the APIs always behave as
9+
if ``add_all=True``),
10+
- ``axes_rgb.imshow_rgb`` (use ``imshow(np.dstack([r, g, b]))`` instead),
11+
- ``RGBAxes.add_RGB_to_figure`` (no replacement),
12+
- ``RGBAxesBase`` (use ``RGBAxes`` instead),
13+
- passing ``None``, or no argument, to ``parasite_axes_class_factory``,
14+
``parasite_axes_auxtrans_class_factory``, ``host_axes_class_factory``
15+
(pass an explicit base class instead),
16+
- the ``den`` parameter and attribute of ``angle_helper.LocatorBase`` (it has
17+
been renamed to ``nbins``),
18+
- ``AxisArtist.dpi_transform`` (no replacement),
19+
- ``grid_finder.MaxNLocator.set_factor`` and ``grid_finder.FixedLocator.set_factor``
20+
(the factor is always 1 now).

‎lib/mpl_toolkits/axes_grid1/axes_grid.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axes_grid1/axes_grid.py
+15-44Lines changed: 15 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,14 @@ def __init__(self, *args, orientation, **kwargs):
2626
super().__init__(*args, **kwargs)
2727

2828
def colorbar(self, mappable, *, ticks=None, **kwargs):
29-
30-
if self.orientation in ["top", "bottom"]:
31-
orientation = "horizontal"
32-
else:
33-
orientation = "vertical"
34-
29+
orientation = (
30+
"horizontal" if self.orientation in ["top", "bottom"] else
31+
"vertical")
3532
cb = mpl.colorbar.Colorbar(
3633
self, mappable, orientation=orientation, ticks=ticks, **kwargs)
37-
self._cbid = mappable.colorbar_cid # deprecated in 3.3.
38-
self._locator = cb.locator # deprecated in 3.3.
39-
4034
self._config_axes()
4135
return cb
4236

43-
cbid = _api.deprecate_privatize_attribute(
44-
"3.3", alternative="mappable.colorbar_cid")
45-
locator = _api.deprecate_privatize_attribute(
46-
"3.3", alternative=".colorbar().locator")
47-
4837
def _config_axes(self):
4938
"""Make an axes patch and outline."""
5039
ax = self
@@ -80,20 +69,18 @@ class Grid:
8069

8170
_defaultAxesClass = Axes
8271

83-
@_api.delete_parameter("3.3", "add_all")
8472
def __init__(self, fig,
8573
rect,
8674
nrows_ncols,
8775
ngrids=None,
8876
direction="row",
8977
axes_pad=0.02,
90-
add_all=True,
78+
*,
9179
share_all=False,
9280
share_x=True,
9381
share_y=True,
9482
label_mode="L",
9583
axes_class=None,
96-
*,
9784
aspect=False,
9885
):
9986
"""
@@ -114,9 +101,6 @@ def __init__(self, fig,
114101
axes_pad : float or (float, float), default: 0.02
115102
Padding or (horizontal padding, vertical padding) between axes, in
116103
inches.
117-
add_all : bool, default: True
118-
Whether to add the axes to the figure using `.Figure.add_axes`.
119-
This parameter is deprecated.
120104
share_all : bool, default: False
121105
Whether all axes share their x- and y-axis. Overrides *share_x*
122106
and *share_y*.
@@ -188,9 +172,8 @@ def __init__(self, fig,
188172

189173
self._init_locators()
190174

191-
if add_all:
192-
for ax in self.axes_all:
193-
fig.add_axes(ax)
175+
for ax in self.axes_all:
176+
fig.add_axes(ax)
194177

195178
self.set_label_mode(label_mode)
196179

@@ -335,14 +318,13 @@ class ImageGrid(Grid):
335318

336319
_defaultCbarAxesClass = CbarAxes
337320

338-
@_api.delete_parameter("3.3", "add_all")
339321
def __init__(self, fig,
340322
rect,
341323
nrows_ncols,
342324
ngrids=None,
343325
direction="row",
344326
axes_pad=0.02,
345-
add_all=True,
327+
*,
346328
share_all=False,
347329
aspect=True,
348330
label_mode="L",
@@ -372,9 +354,6 @@ def __init__(self, fig,
372354
axes_pad : float or (float, float), default: 0.02in
373355
Padding or (horizontal padding, vertical padding) between axes, in
374356
inches.
375-
add_all : bool, default: True
376-
Whether to add the axes to the figure using `.Figure.add_axes`.
377-
This parameter is deprecated.
378357
share_all : bool, default: False
379358
Whether all axes share their x- and y-axis.
380359
aspect : bool, default: True
@@ -409,22 +388,14 @@ def __init__(self, fig,
409388
self._colorbar_size = cbar_size
410389
# The colorbar axes are created in _init_locators().
411390

412-
if add_all:
413-
super().__init__(
414-
fig, rect, nrows_ncols, ngrids,
415-
direction=direction, axes_pad=axes_pad,
416-
share_all=share_all, share_x=True, share_y=True, aspect=aspect,
417-
label_mode=label_mode, axes_class=axes_class)
418-
else: # Only show deprecation in that case.
419-
super().__init__(
420-
fig, rect, nrows_ncols, ngrids,
421-
direction=direction, axes_pad=axes_pad, add_all=add_all,
422-
share_all=share_all, share_x=True, share_y=True, aspect=aspect,
423-
label_mode=label_mode, axes_class=axes_class)
424-
425-
if add_all:
426-
for ax in self.cbar_axes:
427-
fig.add_axes(ax)
391+
super().__init__(
392+
fig, rect, nrows_ncols, ngrids,
393+
direction=direction, axes_pad=axes_pad,
394+
share_all=share_all, share_x=True, share_y=True, aspect=aspect,
395+
label_mode=label_mode, axes_class=axes_class)
396+
397+
for ax in self.cbar_axes:
398+
fig.add_axes(ax)
428399

429400
if cbar_set_cax:
430401
if self._colorbar_mode == "single":

‎lib/mpl_toolkits/axes_grid1/axes_rgb.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axes_grid1/axes_rgb.py
+6-33Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import numpy as np
22

3-
from matplotlib import _api
43
from .axes_divider import make_axes_locatable, Size
54
from .mpl_axes import Axes
65

76

8-
@_api.delete_parameter("3.3", "add_all")
9-
def make_rgb_axes(ax, pad=0.01, axes_class=None, add_all=True, **kwargs):
7+
def make_rgb_axes(ax, pad=0.01, axes_class=None, **kwargs):
108
"""
119
Parameters
1210
----------
@@ -48,19 +46,13 @@ def make_rgb_axes(ax, pad=0.01, axes_class=None, add_all=True, **kwargs):
4846

4947
ax_rgb.append(ax1)
5048

51-
if add_all:
52-
fig = ax.get_figure()
53-
for ax1 in ax_rgb:
54-
fig.add_axes(ax1)
49+
fig = ax.get_figure()
50+
for ax1 in ax_rgb:
51+
fig.add_axes(ax1)
5552

5653
return ax_rgb
5754

5855

59-
@_api.deprecated("3.3", alternative="ax.imshow(np.dstack([r, g, b]))")
60-
def imshow_rgb(ax, r, g, b, **kwargs):
61-
return ax.imshow(np.dstack([r, g, b]), **kwargs)
62-
63-
6456
class RGBAxes:
6557
"""
6658
4-panel imshow (RGB, R, G, B).
@@ -91,16 +83,12 @@ class RGBAxes:
9183

9284
_defaultAxesClass = Axes
9385

94-
@_api.delete_parameter("3.3", "add_all")
95-
def __init__(self, *args, pad=0, add_all=True, **kwargs):
86+
def __init__(self, *args, pad=0, **kwargs):
9687
"""
9788
Parameters
9889
----------
9990
pad : float, default: 0
10091
fraction of the axes height to put as padding.
101-
add_all : bool, default: True
102-
Whether to add the {rgb, r, g, b} axes to the figure.
103-
This parameter is deprecated.
10492
axes_class : matplotlib.axes.Axes
10593
10694
*args
@@ -110,24 +98,14 @@ def __init__(self, *args, pad=0, add_all=True, **kwargs):
11098
"""
11199
axes_class = kwargs.pop("axes_class", self._defaultAxesClass)
112100
self.RGB = ax = axes_class(*args, **kwargs)
113-
if add_all:
114-
ax.get_figure().add_axes(ax)
115-
else:
116-
kwargs["add_all"] = add_all # only show deprecation in that case
101+
ax.get_figure().add_axes(ax)
117102
self.R, self.G, self.B = make_rgb_axes(
118103
ax, pad=pad, axes_class=axes_class, **kwargs)
119104
# Set the line color and ticks for the axes.
120105
for ax1 in [self.RGB, self.R, self.G, self.B]:
121106
ax1.axis[:].line.set_color("w")
122107
ax1.axis[:].major_ticks.set_markeredgecolor("w")
123108

124-
@_api.deprecated("3.3")
125-
def add_RGB_to_figure(self):
126-
"""Add red, green and blue axes to the RGB composite's axes figure."""
127-
self.RGB.get_figure().add_axes(self.R)
128-
self.RGB.get_figure().add_axes(self.G)
129-
self.RGB.get_figure().add_axes(self.B)
130-
131109
def imshow_rgb(self, r, g, b, **kwargs):
132110
"""
133111
Create the four images {rgb, r, g, b}.
@@ -161,8 +139,3 @@ def imshow_rgb(self, r, g, b, **kwargs):
161139
im_g = self.G.imshow(G, **kwargs)
162140
im_b = self.B.imshow(B, **kwargs)
163141
return im_rgb, im_r, im_g, im_b
164-
165-
166-
@_api.deprecated("3.3", alternative="RGBAxes")
167-
class RGBAxesBase(RGBAxes):
168-
pass

‎lib/mpl_toolkits/axes_grid1/parasite_axes.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axes_grid1/parasite_axes.py
+5-30Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,7 @@ def apply_aspect(self, position=None):
9595

9696

9797
@functools.lru_cache(None)
98-
def parasite_axes_class_factory(axes_class=None):
99-
if axes_class is None:
100-
_api.warn_deprecated(
101-
"3.3", message="Support for passing None to "
102-
"parasite_axes_class_factory is deprecated since %(since)s and "
103-
"will be removed %(removal)s; explicitly pass the default Axes "
104-
"class instead.")
105-
axes_class = Axes
106-
98+
def parasite_axes_class_factory(axes_class):
10799
return type("%sParasite" % axes_class.__name__,
108100
(ParasiteAxesBase, axes_class), {})
109101

@@ -158,15 +150,8 @@ def apply_aspect(self, position=None):
158150

159151
@_api.deprecated("3.4", alternative="parasite_axes_class_factory")
160152
@functools.lru_cache(None)
161-
def parasite_axes_auxtrans_class_factory(axes_class=None):
162-
if axes_class is None:
163-
_api.warn_deprecated(
164-
"3.3", message="Support for passing None to "
165-
"parasite_axes_auxtrans_class_factory is deprecated since "
166-
"%(since)s and will be removed %(removal)s; explicitly pass the "
167-
"default ParasiteAxes class instead.")
168-
parasite_axes_class = ParasiteAxes
169-
elif not issubclass(axes_class, ParasiteAxesBase):
153+
def parasite_axes_auxtrans_class_factory(axes_class):
154+
if not issubclass(axes_class, ParasiteAxesBase):
170155
parasite_axes_class = parasite_axes_class_factory(axes_class)
171156
else:
172157
parasite_axes_class = axes_class
@@ -326,20 +311,10 @@ def get_tightbbox(self, renderer, call_axes_locator=True,
326311

327312

328313
@functools.lru_cache(None)
329-
def host_axes_class_factory(axes_class=None):
330-
if axes_class is None:
331-
_api.warn_deprecated(
332-
"3.3", message="Support for passing None to host_axes_class is "
333-
"deprecated since %(since)s and will be removed %(removed)s; "
334-
"explicitly pass the default Axes class instead.")
335-
axes_class = Axes
336-
337-
def _get_base_axes(self):
338-
return axes_class
339-
314+
def host_axes_class_factory(axes_class):
340315
return type("%sHostAxes" % axes_class.__name__,
341316
(HostAxesBase, axes_class),
342-
{'_get_base_axes': _get_base_axes})
317+
{'_get_base_axes': lambda self: axes_class})
343318

344319

345320
def host_subplot_class_factory(axes_class):

‎lib/mpl_toolkits/axisartist/angle_helper.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axisartist/angle_helper.py
-11Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import numpy as np
22
import math
33

4-
from matplotlib import _api
54
from mpl_toolkits.axisartist.grid_finder import ExtremeFinderSimple
65

76

@@ -141,20 +140,10 @@ def select_step360(v1, v2, nv, include_last=True, threshold_factor=3600):
141140

142141

143142
class LocatorBase:
144-
@_api.rename_parameter("3.3", "den", "nbins")
145143
def __init__(self, nbins, include_last=True):
146144
self.nbins = nbins
147145
self._include_last = include_last
148146

149-
@_api.deprecated("3.3", alternative="nbins")
150-
@property
151-
def den(self):
152-
return self.nbins
153-
154-
@den.setter
155-
def den(self, v):
156-
self.nbins = v
157-
158147
def set_params(self, nbins=None):
159148
if nbins is not None:
160149
self.nbins = int(nbins)

‎lib/mpl_toolkits/axisartist/axes_rgb.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axisartist/axes_rgb.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from mpl_toolkits.axes_grid1.axes_rgb import (
2-
make_rgb_axes, imshow_rgb, RGBAxes as _RGBAxes)
1+
from mpl_toolkits.axes_grid1.axes_rgb import make_rgb_axes, RGBAxes as _RGBAxes
32
from .axislines import Axes
43

54

‎lib/mpl_toolkits/axisartist/axis_artist.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axisartist/axis_artist.py
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -673,11 +673,6 @@ def __init__(self, axes,
673673
self._axislabel_add_angle = 0.
674674
self.set_axis_direction(axis_direction)
675675

676-
@_api.deprecated("3.3")
677-
@property
678-
def dpi_transform(self):
679-
return Affine2D().scale(1 / 72) + self.axes.figure.dpi_scale_trans
680-
681676
# axis direction
682677

683678
def set_axis_direction(self, axis_direction):

‎lib/mpl_toolkits/axisartist/grid_finder.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axisartist/grid_finder.py
+5-15Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import numpy as np
22

3-
from matplotlib import _api, ticker as mticker
3+
from matplotlib import ticker as mticker
44
from matplotlib.transforms import Bbox, Transform
55
from .clip_path import clip_line_to_rect
66

@@ -219,30 +219,20 @@ def __init__(self, nbins=10, steps=None,
219219
super().__init__(nbins, steps=steps, integer=integer,
220220
symmetric=symmetric, prune=prune)
221221
self.create_dummy_axis()
222-
self._factor = 1
223222

224223
def __call__(self, v1, v2):
225-
locs = super().tick_values(v1 * self._factor, v2 * self._factor)
226-
return np.array(locs), len(locs), self._factor
227-
228-
@_api.deprecated("3.3")
229-
def set_factor(self, f):
230-
self._factor = f
224+
locs = super().tick_values(v1, v2)
225+
return np.array(locs), len(locs), 1 # 1: factor (see angle_helper)
231226

232227

233228
class FixedLocator:
234229
def __init__(self, locs):
235230
self._locs = locs
236-
self._factor = 1
237231

238232
def __call__(self, v1, v2):
239-
v1, v2 = sorted([v1 * self._factor, v2 * self._factor])
233+
v1, v2 = sorted([v1, v2])
240234
locs = np.array([l for l in self._locs if v1 <= l <= v2])
241-
return locs, len(locs), self._factor
242-
243-
@_api.deprecated("3.3")
244-
def set_factor(self, f):
245-
self._factor = f
235+
return locs, len(locs), 1 # 1: factor (see angle_helper)
246236

247237

248238
# Tick Formatter

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.