Skip to content

Commit 014076e

Browse files
Backport PR matplotlib#31588: Expire some missed deprecations from 3.9 (matplotlib#31592)
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
1 parent b133ac3 commit 014076e

5 files changed

Lines changed: 24 additions & 30 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
``boxplot`` tick labels
2+
^^^^^^^^^^^^^^^^^^^^^^^
3+
4+
The parameter *labels* has been removed in favour of *tick_labels* for clarity and
5+
consistency with `~.Axes.bar`.
6+
7+
Image path semantics of toolmanager-based tools
8+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9+
10+
Previously, MEP22 ("toolmanager-based") Tools would try to load their icon
11+
(``tool.image``) relative to the current working directory, or, as a fallback, from
12+
Matplotlib's own image directory. Because both approaches are problematic for
13+
third-party tools (the end-user may change the current working directory at any time,
14+
and third-parties cannot add new icons in Matplotlib's image directory), this behavior
15+
has been removed; instead, ``tool.image`` is now interpreted relative to the directory
16+
containing the source file where the ``Tool.image`` class attribute is defined.
17+
(Defining ``tool.image`` as an absolute path also works and is compatible with both the
18+
old and the new semantics.)

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4302,7 +4302,6 @@ def apply_mask(arrays, mask):
43024302

43034303
@_api.make_keyword_only("3.10", "notch")
43044304
@_preprocess_data()
4305-
@_api.rename_parameter("3.9", "labels", "tick_labels")
43064305
def boxplot(self, x, notch=None, sym=None, vert=None,
43074306
orientation='vertical', whis=None, positions=None,
43084307
widths=None, patch_artist=None, bootstrap=None,
@@ -4444,8 +4443,7 @@ def boxplot(self, x, notch=None, sym=None, vert=None,
44444443
values.
44454444
44464445
.. versionchanged:: 3.9
4447-
Renamed from *labels*, which is deprecated since 3.9
4448-
and will be removed in 3.11.
4446+
Renamed from *labels*, which is also removed in 3.11.
44494447
44504448
manage_ticks : bool, default: True
44514449
If True, the tick locations and labels will be adjusted to match

lib/matplotlib/backend_bases.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3516,20 +3516,6 @@ def _get_image_filename(self, tool):
35163516
for filename in [filename, filename + self._icon_extension]:
35173517
if os.path.isfile(filename):
35183518
return os.path.abspath(filename)
3519-
for fname in [ # Fallback; once deprecation elapses.
3520-
tool.image,
3521-
tool.image + self._icon_extension,
3522-
cbook._get_data_path("images", tool.image),
3523-
cbook._get_data_path("images", tool.image + self._icon_extension),
3524-
]:
3525-
if os.path.isfile(fname):
3526-
_api.warn_deprecated(
3527-
"3.9", message=f"Loading icon {tool.image!r} from the current "
3528-
"directory or from Matplotlib's image directory. This behavior "
3529-
"is deprecated since %(since)s and will be removed in %(removal)s; "
3530-
"Tool.image should be set to a path relative to the Tool's source "
3531-
"file, or to an absolute path.")
3532-
return os.path.abspath(fname)
35333519

35343520
def trigger_tool(self, name):
35353521
"""

lib/matplotlib/hatch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def _validate_hatch_pattern(hatch):
206206
invalids = ''.join(sorted(invalids))
207207
_api.warn_deprecated(
208208
'3.4',
209-
removal='3.11', # one release after custom hatches (#20690)
209+
removal='3.13', # one release after custom hatches (#20690)
210210
message=f'hatch must consist of a string of "{valid}" or '
211211
'None, but found the following invalid values '
212212
f'"{invalids}". Passing invalid values is deprecated '

lib/matplotlib/tests/test_axes.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10047,21 +10047,13 @@ def assert_not_in_reference_cycle(start):
1004710047

1004810048

1004910049
def test_boxplot_tick_labels():
10050-
# Test the renamed `tick_labels` parameter.
10051-
# Test for deprecation of old name `labels`.
10050+
# Test the `tick_labels` parameter.
1005210051
np.random.seed(19680801)
1005310052
data = np.random.random((10, 3))
1005410053

10055-
fig, axs = plt.subplots(nrows=1, ncols=2, sharey=True)
10056-
# Should get deprecation warning for `labels`
10057-
with pytest.warns(mpl.MatplotlibDeprecationWarning,
10058-
match='has been renamed \'tick_labels\''):
10059-
axs[0].boxplot(data, labels=['A', 'B', 'C'])
10060-
assert [l.get_text() for l in axs[0].get_xticklabels()] == ['A', 'B', 'C']
10061-
10062-
# Test the new tick_labels parameter
10063-
axs[1].boxplot(data, tick_labels=['A', 'B', 'C'])
10064-
assert [l.get_text() for l in axs[1].get_xticklabels()] == ['A', 'B', 'C']
10054+
fig, ax = plt.subplots()
10055+
ax.boxplot(data, tick_labels=['A', 'B', 'C'])
10056+
assert [l.get_text() for l in ax.get_xticklabels()] == ['A', 'B', 'C']
1006510057

1006610058

1006710059
@needs_usetex

0 commit comments

Comments
 (0)