diff --git a/doc/api/next_api_changes/removals/27968-ES.rst b/doc/api/next_api_changes/removals/27968-ES.rst new file mode 100644 index 000000000000..99b3b1527506 --- /dev/null +++ b/doc/api/next_api_changes/removals/27968-ES.rst @@ -0,0 +1,14 @@ +``legend.legendHandles`` +~~~~~~~~~~~~~~~~~~~~~~~~ + +... was undocumented and has been renamed to ``legend_handles``. + +Passing undefined *label_mode* to ``Grid`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +... is no longer allowed. This includes `mpl_toolkits.axes_grid1.axes_grid.Grid`, +`mpl_toolkits.axes_grid1.axes_grid.AxesGrid`, and +`mpl_toolkits.axes_grid1.axes_grid.ImageGrid` as well as the corresponding classes +imported from `mpl_toolkits.axisartist.axes_grid`. + +Pass ``label_mode='keep'`` instead to get the previous behavior of not modifying labels. diff --git a/lib/matplotlib/legend.py b/lib/matplotlib/legend.py index 111e08e00869..9033fc23c1a1 100644 --- a/lib/matplotlib/legend.py +++ b/lib/matplotlib/legend.py @@ -633,9 +633,6 @@ def __init__( else: raise ValueError(f"Invalid labelcolor: {labelcolor!r}") - legendHandles = _api.deprecated('3.7', alternative="legend_handles")( - property(lambda self: self.legend_handles)) - def _set_artist_props(self, a): """ Set the boilerplate props for artists added to Axes. diff --git a/lib/matplotlib/legend.pyi b/lib/matplotlib/legend.pyi index d559b06c5d5d..dde5882da69d 100644 --- a/lib/matplotlib/legend.pyi +++ b/lib/matplotlib/legend.pyi @@ -150,5 +150,3 @@ class Legend(Artist): update: Literal["loc", "bbox"] = ..., ) -> None: ... def get_draggable(self) -> bool: ... - @property - def legendHandles(self) -> list[Artist | None]: ... diff --git a/lib/mpl_toolkits/axes_grid1/axes_grid.py b/lib/mpl_toolkits/axes_grid1/axes_grid.py index 720d985414ff..1c4551092c24 100644 --- a/lib/mpl_toolkits/axes_grid1/axes_grid.py +++ b/lib/mpl_toolkits/axes_grid1/axes_grid.py @@ -234,6 +234,7 @@ def set_label_mode(self, mode): - "all": All axes are labelled. - "keep": Do not do anything. """ + _api.check_in_list(["all", "L", "1", "keep"], mode=mode) is_last_row, is_first_col = ( np.mgrid[:self._nrows, :self._ncols] == [[[self._nrows - 1]], [[0]]]) if mode == "all": @@ -244,15 +245,6 @@ def set_label_mode(self, mode): elif mode == "1": bottom = left = is_last_row & is_first_col else: - # Use _api.check_in_list at the top of the method when deprecation - # period expires - if mode != 'keep': - _api.warn_deprecated( - '3.7', name="Grid label_mode", - message='Passing an undefined label_mode is deprecated ' - 'since %(since)s and will become an error ' - '%(removal)s. To silence this warning, pass ' - '"keep", which gives the same behaviour.') return for i in range(self._nrows): for j in range(self._ncols): diff --git a/lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py b/lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py index b1a18d77747e..56f07c026b97 100644 --- a/lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py +++ b/lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py @@ -432,13 +432,10 @@ def test_image_grid_single_bottom(): grid.cbar_axes[0].colorbar(im) -def test_image_grid_label_mode_deprecation_warning(): - imdata = np.arange(9).reshape((3, 3)) - +def test_image_grid_label_mode_invalid(): fig = plt.figure() - with pytest.warns(mpl.MatplotlibDeprecationWarning, - match="Passing an undefined label_mode"): - grid = ImageGrid(fig, (0, 0, 1, 1), (2, 1), label_mode="foo") + with pytest.raises(ValueError, match="'foo' is not a valid value for mode"): + ImageGrid(fig, (0, 0, 1, 1), (2, 1), label_mode="foo") @image_comparison(['image_grid.png'],