Skip to content

Commit da2f549

Browse files
committed
Remove 3.8 deprecations in toolkits
1 parent 6404c95 commit da2f549

File tree

18 files changed

+51
-272
lines changed

18 files changed

+51
-272
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
``axes_grid1`` API changes
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
``anchored_artists.AnchoredEllipse`` has been removed. Instead, directly construct an
5+
`.AnchoredOffsetbox`, an `.AuxTransformBox`, and an `~.patches.Ellipse`, as demonstrated
6+
in :doc:`/gallery/misc/anchored_artists`.
7+
8+
The ``axes_divider.AxesLocator`` class has been removed. The ``new_locator`` method of
9+
divider instances now instead returns an opaque callable (which can still be passed to
10+
``ax.set_axes_locator``).
11+
12+
``axes_divider.Divider.locate`` has been removed; use ``Divider.new_locator(...)(ax,
13+
renderer)`` instead.
14+
15+
``axes_grid.CbarAxesBase.toggle_label`` has been removed. Instead, use standard methods
16+
for manipulating colorbar labels (`.Colorbar.set_label`) and tick labels
17+
(`.Axes.tick_params`).
18+
19+
``inset_location.InsetPosition`` has been removed; use `~.Axes.inset_axes` instead.
20+
21+
22+
``axisartist`` API changes
23+
~~~~~~~~~~~~~~~~~~~~~~~~~~
24+
25+
The ``axisartist.axes_grid`` and ``axisartist.axes_rgb`` modules, which provide wrappers
26+
combining the functionality of `.axes_grid1` and `.axisartist`, have been removed;
27+
directly use e.g. ``AxesGrid(..., axes_class=axislines.Axes)`` instead.
28+
29+
Calling an axisartist Axes to mean `~matplotlib.pyplot.axis` has been removed; explicitly
30+
call the method instead.
31+
32+
``floating_axes.GridHelperCurveLinear.get_data_boundary`` has been removed. Use
33+
``grid_finder.extreme_finder(*[None] * 5)`` to get the extremes of the grid.

doc/api/prev_api_changes/api_changes_3.6.0/behaviour.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ Specified exception types in ``Grid``
241241

242242
In a few cases an `Exception` was thrown when an incorrect argument value was
243243
set in the `mpl_toolkits.axes_grid1.axes_grid.Grid` (=
244-
`mpl_toolkits.axisartist.axes_grid.Grid`) constructor. These are replaced as
244+
``mpl_toolkits.axisartist.axes_grid.Grid``) constructor. These are replaced as
245245
follows:
246246

247247
* Providing an incorrect value for *ngrids* now raises a `ValueError`

doc/api/prev_api_changes/api_changes_3.7.0/deprecations.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Passing undefined *label_mode* to ``Grid``
9090
... is deprecated. This includes `mpl_toolkits.axes_grid1.axes_grid.Grid`,
9191
`mpl_toolkits.axes_grid1.axes_grid.AxesGrid`, and
9292
`mpl_toolkits.axes_grid1.axes_grid.ImageGrid` as well as the corresponding
93-
classes imported from `mpl_toolkits.axisartist.axes_grid`.
93+
classes imported from ``mpl_toolkits.axisartist.axes_grid``.
9494

9595
Pass ``label_mode='keep'`` instead to get the previous behavior of not modifying labels.
9696

doc/api/prev_api_changes/api_changes_3.9.0/removals.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Passing undefined *label_mode* to ``Grid``
111111
... is no longer allowed. This includes `mpl_toolkits.axes_grid1.axes_grid.Grid`,
112112
`mpl_toolkits.axes_grid1.axes_grid.AxesGrid`, and
113113
`mpl_toolkits.axes_grid1.axes_grid.ImageGrid` as well as the corresponding classes
114-
imported from `mpl_toolkits.axisartist.axes_grid`.
114+
imported from ``mpl_toolkits.axisartist.axes_grid``.
115115

116116
Pass ``label_mode='keep'`` instead to get the previous behavior of not modifying labels.
117117

doc/api/toolkits/axisartist.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ You can find a tutorial describing usage of axisartist at the
3434

3535
axisartist.angle_helper
3636
axisartist.axes_divider
37-
axisartist.axes_grid
38-
axisartist.axes_rgb
3937
axisartist.axis_artist
4038
axisartist.axisline_style
4139
axisartist.axislines

lib/mpl_toolkits/axes_grid1/anchored_artists.py

Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from matplotlib import _api, transforms
1+
from matplotlib import transforms
22
from matplotlib.offsetbox import (AnchoredOffsetbox, AuxTransformBox,
33
DrawingArea, TextArea, VPacker)
4-
from matplotlib.patches import (Rectangle, Ellipse, ArrowStyle,
4+
from matplotlib.patches import (Rectangle, ArrowStyle,
55
FancyArrowPatch, PathPatch)
66
from matplotlib.text import TextPath
77

88
__all__ = ['AnchoredDrawingArea', 'AnchoredAuxTransformBox',
9-
'AnchoredEllipse', 'AnchoredSizeBar', 'AnchoredDirectionArrows']
9+
'AnchoredSizeBar', 'AnchoredDirectionArrows']
1010

1111

1212
class AnchoredDrawingArea(AnchoredOffsetbox):
@@ -124,54 +124,6 @@ def __init__(self, transform, loc,
124124
**kwargs)
125125

126126

127-
@_api.deprecated("3.8")
128-
class AnchoredEllipse(AnchoredOffsetbox):
129-
def __init__(self, transform, width, height, angle, loc,
130-
pad=0.1, borderpad=0.1, prop=None, frameon=True, **kwargs):
131-
"""
132-
Draw an anchored ellipse of a given size.
133-
134-
Parameters
135-
----------
136-
transform : `~matplotlib.transforms.Transform`
137-
The transformation object for the coordinate system in use, i.e.,
138-
:attr:`matplotlib.axes.Axes.transData`.
139-
width, height : float
140-
Width and height of the ellipse, given in coordinates of
141-
*transform*.
142-
angle : float
143-
Rotation of the ellipse, in degrees, anti-clockwise.
144-
loc : str
145-
Location of the ellipse. Valid locations are
146-
'upper left', 'upper center', 'upper right',
147-
'center left', 'center', 'center right',
148-
'lower left', 'lower center', 'lower right'.
149-
For backward compatibility, numeric values are accepted as well.
150-
See the parameter *loc* of `.Legend` for details.
151-
pad : float, default: 0.1
152-
Padding around the ellipse, in fraction of the font size.
153-
borderpad : float, default: 0.1
154-
Border padding, in fraction of the font size.
155-
frameon : bool, default: True
156-
If True, draw a box around the ellipse.
157-
prop : `~matplotlib.font_manager.FontProperties`, optional
158-
Font property used as a reference for paddings.
159-
**kwargs
160-
Keyword arguments forwarded to `.AnchoredOffsetbox`.
161-
162-
Attributes
163-
----------
164-
ellipse : `~matplotlib.patches.Ellipse`
165-
Ellipse patch drawn.
166-
"""
167-
self._box = AuxTransformBox(transform)
168-
self.ellipse = Ellipse((0, 0), width, height, angle=angle)
169-
self._box.add_artist(self.ellipse)
170-
171-
super().__init__(loc, pad=pad, borderpad=borderpad, child=self._box,
172-
prop=prop, frameon=frameon, **kwargs)
173-
174-
175127
class AnchoredSizeBar(AnchoredOffsetbox):
176128
def __init__(self, transform, size, label, loc,
177129
pad=0.1, borderpad=0.1, sep=2,

lib/mpl_toolkits/axes_grid1/axes_divider.py

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -199,31 +199,6 @@ def new_locator(self, nx, ny, nx1=None, ny1=None):
199199
locator.get_subplotspec = self.get_subplotspec
200200
return locator
201201

202-
@_api.deprecated(
203-
"3.8", alternative="divider.new_locator(...)(ax, renderer)")
204-
def locate(self, nx, ny, nx1=None, ny1=None, axes=None, renderer=None):
205-
"""
206-
Implementation of ``divider.new_locator().__call__``.
207-
208-
Parameters
209-
----------
210-
nx, nx1 : int
211-
Integers specifying the column-position of the cell. When *nx1* is
212-
None, a single *nx*-th column is specified. Otherwise, the
213-
location of columns spanning between *nx* to *nx1* (but excluding
214-
*nx1*-th column) is specified.
215-
ny, ny1 : int
216-
Same as *nx* and *nx1*, but for row positions.
217-
axes
218-
renderer
219-
"""
220-
xref = self._xrefindex
221-
yref = self._yrefindex
222-
return self._locate(
223-
nx - xref, (nx + 1 if nx1 is None else nx1) - xref,
224-
ny - yref, (ny + 1 if ny1 is None else ny1) - yref,
225-
axes, renderer)
226-
227202
def _locate(self, nx, ny, nx1, ny1, axes, renderer):
228203
"""
229204
Implementation of ``divider.new_locator().__call__``.
@@ -305,57 +280,6 @@ def add_auto_adjustable_area(self, use_axes, pad=0.1, adjust_dirs=None):
305280
self.append_size(d, Size._AxesDecorationsSize(use_axes, d) + pad)
306281

307282

308-
@_api.deprecated("3.8")
309-
class AxesLocator:
310-
"""
311-
A callable object which returns the position and size of a given
312-
`.AxesDivider` cell.
313-
"""
314-
315-
def __init__(self, axes_divider, nx, ny, nx1=None, ny1=None):
316-
"""
317-
Parameters
318-
----------
319-
axes_divider : `~mpl_toolkits.axes_grid1.axes_divider.AxesDivider`
320-
nx, nx1 : int
321-
Integers specifying the column-position of the
322-
cell. When *nx1* is None, a single *nx*-th column is
323-
specified. Otherwise, location of columns spanning between *nx*
324-
to *nx1* (but excluding *nx1*-th column) is specified.
325-
ny, ny1 : int
326-
Same as *nx* and *nx1*, but for row positions.
327-
"""
328-
self._axes_divider = axes_divider
329-
330-
_xrefindex = axes_divider._xrefindex
331-
_yrefindex = axes_divider._yrefindex
332-
333-
self._nx, self._ny = nx - _xrefindex, ny - _yrefindex
334-
335-
if nx1 is None:
336-
nx1 = len(self._axes_divider)
337-
if ny1 is None:
338-
ny1 = len(self._axes_divider[0])
339-
340-
self._nx1 = nx1 - _xrefindex
341-
self._ny1 = ny1 - _yrefindex
342-
343-
def __call__(self, axes, renderer):
344-
345-
_xrefindex = self._axes_divider._xrefindex
346-
_yrefindex = self._axes_divider._yrefindex
347-
348-
return self._axes_divider.locate(self._nx + _xrefindex,
349-
self._ny + _yrefindex,
350-
self._nx1 + _xrefindex,
351-
self._ny1 + _yrefindex,
352-
axes,
353-
renderer)
354-
355-
def get_subplotspec(self):
356-
return self._axes_divider.get_subplotspec()
357-
358-
359283
class SubplotDivider(Divider):
360284
"""
361285
The Divider class whose rectangle area is specified as a subplot geometry.

lib/mpl_toolkits/axes_grid1/axes_grid.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ def colorbar(self, mappable, **kwargs):
2020
return self.get_figure(root=False).colorbar(
2121
mappable, cax=self, location=self.orientation, **kwargs)
2222

23-
@_api.deprecated("3.8", alternative="ax.tick_params and colorbar.set_label")
24-
def toggle_label(self, b):
25-
axis = self.axis[self.orientation]
26-
axis.toggle(ticklabels=b, label=b)
27-
2823

2924
_cbaraxes_class_factory = cbook._make_class_factory(CbarAxesBase, "Cbar{}")
3025

lib/mpl_toolkits/axes_grid1/inset_locator.py

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,58 +6,13 @@
66
from matplotlib.offsetbox import AnchoredOffsetbox
77
from matplotlib.patches import Patch, Rectangle
88
from matplotlib.path import Path
9-
from matplotlib.transforms import Bbox, BboxTransformTo
9+
from matplotlib.transforms import Bbox
1010
from matplotlib.transforms import IdentityTransform, TransformedBbox
1111

1212
from . import axes_size as Size
1313
from .parasite_axes import HostAxes
1414

1515

16-
@_api.deprecated("3.8", alternative="Axes.inset_axes")
17-
class InsetPosition:
18-
@_docstring.interpd
19-
def __init__(self, parent, lbwh):
20-
"""
21-
An object for positioning an inset axes.
22-
23-
This is created by specifying the normalized coordinates in the axes,
24-
instead of the figure.
25-
26-
Parameters
27-
----------
28-
parent : `~matplotlib.axes.Axes`
29-
Axes to use for normalizing coordinates.
30-
31-
lbwh : iterable of four floats
32-
The left edge, bottom edge, width, and height of the inset axes, in
33-
units of the normalized coordinate of the *parent* axes.
34-
35-
See Also
36-
--------
37-
:meth:`matplotlib.axes.Axes.set_axes_locator`
38-
39-
Examples
40-
--------
41-
The following bounds the inset axes to a box with 20%% of the parent
42-
axes height and 40%% of the width. The size of the axes specified
43-
([0, 0, 1, 1]) ensures that the axes completely fills the bounding box:
44-
45-
>>> parent_axes = plt.gca()
46-
>>> ax_ins = plt.axes([0, 0, 1, 1])
47-
>>> ip = InsetPosition(parent_axes, [0.5, 0.1, 0.4, 0.2])
48-
>>> ax_ins.set_axes_locator(ip)
49-
"""
50-
self.parent = parent
51-
self.lbwh = lbwh
52-
53-
def __call__(self, ax, renderer):
54-
bbox_parent = self.parent.get_position(original=False)
55-
trans = BboxTransformTo(bbox_parent)
56-
bbox_inset = Bbox.from_bounds(*self.lbwh)
57-
bb = TransformedBbox(bbox_inset, trans)
58-
return bb
59-
60-
6116
class AnchoredLocatorBase(AnchoredOffsetbox):
6217
def __init__(self, bbox_to_anchor, offsetbox, loc,
6318
borderpad=0.5, bbox_transform=None):

0 commit comments

Comments
 (0)