From 0e541df4dd87589cc7a68e3044ed7c166c88600e Mon Sep 17 00:00:00 2001 From: Greg Lucas Date: Thu, 19 May 2022 20:24:18 -0600 Subject: [PATCH 01/11] MNT: Remove get/set window title methods from FigureCanvas This is the removal after the deprecation period. --- .../next_api_changes/removals/23XXX-GL.rst | 5 +++++ lib/matplotlib/backend_bases.py | 20 ------------------- 2 files changed, 5 insertions(+), 20 deletions(-) create mode 100644 doc/api/next_api_changes/removals/23XXX-GL.rst diff --git a/doc/api/next_api_changes/removals/23XXX-GL.rst b/doc/api/next_api_changes/removals/23XXX-GL.rst new file mode 100644 index 000000000000..f4e3d3bc38f9 --- /dev/null +++ b/doc/api/next_api_changes/removals/23XXX-GL.rst @@ -0,0 +1,5 @@ +Get/set window title methods have been removed from the canvas +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Use the corresponding methods on the FigureManager if using pyplot, +or GUI-specific methods if embedding. diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index f70be0d91b94..4e7cfbf4c5d6 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -2307,26 +2307,6 @@ def get_default_filetype(cls): """ return rcParams['savefig.format'] - @_api.deprecated("3.4", alternative="`.FigureManagerBase.get_window_title`" - " or GUI-specific methods") - def get_window_title(self): - """ - Return the title text of the window containing the figure, or None - if there is no window (e.g., a PS backend). - """ - if self.manager is not None: - return self.manager.get_window_title() - - @_api.deprecated("3.4", alternative="`.FigureManagerBase.set_window_title`" - " or GUI-specific methods") - def set_window_title(self, title): - """ - Set the title text of the window containing the figure. Note that - this has no effect if there is no window (e.g., a PS backend). - """ - if self.manager is not None: - self.manager.set_window_title(title) - def get_default_filename(self): """ Return a string, which includes extension, suitable for use as From de85cf69b7ec33b377f4a7d06e8c28eebf8e8178 Mon Sep 17 00:00:00 2001 From: Greg Lucas Date: Sat, 21 May 2022 17:54:56 -0600 Subject: [PATCH 02/11] MNT: Remove deprecated get_label_coords from contourLabeler --- .../next_api_changes/removals/23XXX-GL.rst | 6 +++++ lib/matplotlib/contour.py | 25 ------------------- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/doc/api/next_api_changes/removals/23XXX-GL.rst b/doc/api/next_api_changes/removals/23XXX-GL.rst index f4e3d3bc38f9..24a8fcff9787 100644 --- a/doc/api/next_api_changes/removals/23XXX-GL.rst +++ b/doc/api/next_api_changes/removals/23XXX-GL.rst @@ -3,3 +3,9 @@ Get/set window title methods have been removed from the canvas Use the corresponding methods on the FigureManager if using pyplot, or GUI-specific methods if embedding. + +``ContourLabeler.get_label_coords()`` has been removed +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +There is no replacement, it was considered an internal helper. + diff --git a/lib/matplotlib/contour.py b/lib/matplotlib/contour.py index a8c72fafd6f6..2b34c3f524c8 100644 --- a/lib/matplotlib/contour.py +++ b/lib/matplotlib/contour.py @@ -248,31 +248,6 @@ def too_close(self, x, y, lw): return any((x - loc[0]) ** 2 + (y - loc[1]) ** 2 < thresh for loc in self.labelXYs) - @_api.deprecated("3.4") - def get_label_coords(self, distances, XX, YY, ysize, lw): - """ - Return x, y, and the index of a label location. - - Labels are plotted at a location with the smallest - deviation of the contour from a straight line - unless there is another label nearby, in which case - the next best place on the contour is picked up. - If all such candidates are rejected, the beginning - of the contour is chosen. - """ - hysize = int(ysize / 2) - adist = np.argsort(distances) - - for ind in adist: - x, y = XX[ind][hysize], YY[ind][hysize] - if self.too_close(x, y, lw): - continue - return x, y, ind - - ind = adist[0] - x, y = XX[ind][hysize], YY[ind][hysize] - return x, y, ind - def _get_nth_label_width(self, nth): """Return the width of the *nth* label, in pixels.""" fig = self.axes.figure From 59f743e65a8cf249775a97eec53844e2285ad35b Mon Sep 17 00:00:00 2001 From: Greg Lucas Date: Sat, 21 May 2022 18:46:51 -0600 Subject: [PATCH 03/11] MNT: Remove return_all kwarg from gridspec get_position This follows the deprecation period. --- doc/api/next_api_changes/removals/23XXX-GL.rst | 2 ++ lib/matplotlib/gridspec.py | 10 ++-------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/doc/api/next_api_changes/removals/23XXX-GL.rst b/doc/api/next_api_changes/removals/23XXX-GL.rst index 24a8fcff9787..b82def7fc95e 100644 --- a/doc/api/next_api_changes/removals/23XXX-GL.rst +++ b/doc/api/next_api_changes/removals/23XXX-GL.rst @@ -9,3 +9,5 @@ or GUI-specific methods if embedding. There is no replacement, it was considered an internal helper. +The **return_all** keyword argument has been removed from ``gridspec.get_position()`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/matplotlib/gridspec.py b/lib/matplotlib/gridspec.py index 90d0b57b609b..91b42f69516f 100644 --- a/lib/matplotlib/gridspec.py +++ b/lib/matplotlib/gridspec.py @@ -664,8 +664,7 @@ def is_first_col(self): def is_last_col(self): return self.colspan.stop == self.get_gridspec().ncols - @_api.delete_parameter("3.4", "return_all") - def get_position(self, figure, return_all=False): + def get_position(self, figure): """ Update the subplot position from ``figure.subplotpars``. """ @@ -679,12 +678,7 @@ def get_position(self, figure, return_all=False): fig_top = fig_tops[rows].max() fig_left = fig_lefts[cols].min() fig_right = fig_rights[cols].max() - figbox = Bbox.from_extents(fig_left, fig_bottom, fig_right, fig_top) - - if return_all: - return figbox, rows[0], cols[0], nrows, ncols - else: - return figbox + return Bbox.from_extents(fig_left, fig_bottom, fig_right, fig_top) def get_topmost_subplotspec(self): """ From c78d16dde27b86092821f70bf86cebf1ff485de2 Mon Sep 17 00:00:00 2001 From: Greg Lucas Date: Sat, 21 May 2022 18:53:34 -0600 Subject: [PATCH 04/11] MNT: Remove minimum_descent from TextArea This follows the deprecation period. --- .../next_api_changes/removals/23XXX-GL.rst | 5 ++++ lib/matplotlib/offsetbox.py | 26 ------------------- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/doc/api/next_api_changes/removals/23XXX-GL.rst b/doc/api/next_api_changes/removals/23XXX-GL.rst index b82def7fc95e..ff195825a2f8 100644 --- a/doc/api/next_api_changes/removals/23XXX-GL.rst +++ b/doc/api/next_api_changes/removals/23XXX-GL.rst @@ -11,3 +11,8 @@ There is no replacement, it was considered an internal helper. The **return_all** keyword argument has been removed from ``gridspec.get_position()`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The **minimum_descent** has been removed from ``TextArea`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The minimum_descent is now effectively always True. diff --git a/lib/matplotlib/offsetbox.py b/lib/matplotlib/offsetbox.py index 229158066675..40dd6901325a 100644 --- a/lib/matplotlib/offsetbox.py +++ b/lib/matplotlib/offsetbox.py @@ -688,11 +688,9 @@ class TextArea(OffsetBox): child text. """ - @_api.delete_parameter("3.4", "minimumdescent") def __init__(self, s, textprops=None, multilinebaseline=False, - minimumdescent=True, ): """ Parameters @@ -705,9 +703,6 @@ def __init__(self, s, multilinebaseline : bool, default: False Whether the baseline for multiline text is adjusted so that it is (approximately) center-aligned with single-line text. - minimumdescent : bool, default: True - If `True`, the box has a minimum descent of "p". This is now - effectively always True. """ if textprops is None: textprops = {} @@ -719,7 +714,6 @@ def __init__(self, s, self._text.set_transform(self.offset_transform + self._baseline_transform) self._multilinebaseline = multilinebaseline - self._minimumdescent = minimumdescent def set_text(self, s): """Set the text of this area as a string.""" @@ -748,26 +742,6 @@ def get_multilinebaseline(self): """ return self._multilinebaseline - @_api.deprecated("3.4") - def set_minimumdescent(self, t): - """ - Set minimumdescent. - - If True, extent of the single line text is adjusted so that - its descent is at least the one of the glyph "p". - """ - # The current implementation of Text._get_layout always behaves as if - # this is True. - self._minimumdescent = t - self.stale = True - - @_api.deprecated("3.4") - def get_minimumdescent(self): - """ - Get minimumdescent. - """ - return self._minimumdescent - def set_transform(self, t): """ set_transform is ignored. From 01dd9c2902a230eebf8cfb952a2e57b730b2994a Mon Sep 17 00:00:00 2001 From: Greg Lucas Date: Sat, 21 May 2022 19:05:21 -0600 Subject: [PATCH 05/11] MNT: Make optional parameters to Axes keyword only This follows the deprecation period. --- doc/api/next_api_changes/removals/23XXX-GL.rst | 5 +++++ lib/matplotlib/axes/_base.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/api/next_api_changes/removals/23XXX-GL.rst b/doc/api/next_api_changes/removals/23XXX-GL.rst index ff195825a2f8..bfa75de4863b 100644 --- a/doc/api/next_api_changes/removals/23XXX-GL.rst +++ b/doc/api/next_api_changes/removals/23XXX-GL.rst @@ -16,3 +16,8 @@ The **minimum_descent** has been removed from ``TextArea`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The minimum_descent is now effectively always True. + +Extra parameters to Axes constructor +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Parameters of the Axes constructor other than *fig* and *rect* are now keyword only. diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 6daad3ca450a..948a90f6f838 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -562,8 +562,8 @@ def __str__(self): return "{0}({1[0]:g},{1[1]:g};{1[2]:g}x{1[3]:g})".format( type(self).__name__, self._position.bounds) - @_api.make_keyword_only("3.4", "facecolor") def __init__(self, fig, rect, + *, facecolor=None, # defaults to rc axes.facecolor frameon=True, sharex=None, # use Axes instance's xaxis info From 3f7a55203cfcd843ab5b3ddfc1a4c93cffbf4fcd Mon Sep 17 00:00:00 2001 From: Greg Lucas Date: Sat, 21 May 2022 19:09:30 -0600 Subject: [PATCH 06/11] MNT: Remove the renamed parameter s to signal in callback registry This follows the deprecation period. --- lib/matplotlib/cbook/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/matplotlib/cbook/__init__.py b/lib/matplotlib/cbook/__init__.py index 5a955ed459c5..debc3a1ea980 100644 --- a/lib/matplotlib/cbook/__init__.py +++ b/lib/matplotlib/cbook/__init__.py @@ -206,7 +206,6 @@ def __setstate__(self, state): s: {proxy: cid for cid, proxy in d.items()} for s, d in self.callbacks.items()} - @_api.rename_parameter("3.4", "s", "signal") def connect(self, signal, func): """Register *func* to be called when signal *signal* is generated.""" if signal == "units finalize": From feaf336cd85dcf0acc4b795130c72ed22df8741f Mon Sep 17 00:00:00 2001 From: Greg Lucas Date: Sat, 21 May 2022 19:15:36 -0600 Subject: [PATCH 07/11] MNT: Remove align from sphinxext.plot_directive This follows the deprecation period. --- doc/api/next_api_changes/removals/23XXX-GL.rst | 5 +++++ lib/matplotlib/sphinxext/plot_directive.py | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/api/next_api_changes/removals/23XXX-GL.rst b/doc/api/next_api_changes/removals/23XXX-GL.rst index bfa75de4863b..ef488ccc8c79 100644 --- a/doc/api/next_api_changes/removals/23XXX-GL.rst +++ b/doc/api/next_api_changes/removals/23XXX-GL.rst @@ -21,3 +21,8 @@ Extra parameters to Axes constructor ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Parameters of the Axes constructor other than *fig* and *rect* are now keyword only. + +``sphinext.plot_directive.align`` has been removed +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Use ``docutils.parsers.rst.directives.images.Image.align`` instead. diff --git a/lib/matplotlib/sphinxext/plot_directive.py b/lib/matplotlib/sphinxext/plot_directive.py index 215e3c4b8c3f..00b10aaa4d99 100644 --- a/lib/matplotlib/sphinxext/plot_directive.py +++ b/lib/matplotlib/sphinxext/plot_directive.py @@ -162,9 +162,6 @@ from matplotlib import _api, _pylab_helpers, cbook matplotlib.use("agg") -align = _api.deprecated( - "3.4", alternative="docutils.parsers.rst.directives.images.Image.align")( - Image.align) __version__ = 2 From 2cb39f92ad4a727dce867fb0cb9fddf7be8b1a26 Mon Sep 17 00:00:00 2001 From: Greg Lucas Date: Sat, 21 May 2022 19:45:48 -0600 Subject: [PATCH 08/11] MNT: Remove ability to pass URLs to imread() This follows the deprecation period. --- .../next_api_changes/removals/23XXX-GL.rst | 8 +++++ lib/matplotlib/image.py | 30 +++++-------------- lib/matplotlib/tests/test_image.py | 11 ++----- 3 files changed, 17 insertions(+), 32 deletions(-) diff --git a/doc/api/next_api_changes/removals/23XXX-GL.rst b/doc/api/next_api_changes/removals/23XXX-GL.rst index ef488ccc8c79..57f28f3550cc 100644 --- a/doc/api/next_api_changes/removals/23XXX-GL.rst +++ b/doc/api/next_api_changes/removals/23XXX-GL.rst @@ -26,3 +26,11 @@ Parameters of the Axes constructor other than *fig* and *rect* are now keyword o ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Use ``docutils.parsers.rst.directives.images.Image.align`` instead. + +``imread()`` no longer accepts URLs +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Passing a URL to `~.pyplot.imread()` has been removed. Please open the URL for +reading and directly use the Pillow API +(``PIL.Image.open(urllib.request.urlopen(url))``, or +``PIL.Image.open(io.BytesIO(requests.get(url).content))``) instead. diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index 13776101b165..f8a93c4d7757 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -1526,29 +1526,13 @@ def imread(fname, format=None): ext = format img_open = ( PIL.PngImagePlugin.PngImageFile if ext == 'png' else PIL.Image.open) - if isinstance(fname, str): - parsed = parse.urlparse(fname) - if len(parsed.scheme) > 1: # Pillow doesn't handle URLs directly. - _api.warn_deprecated( - "3.4", message="Directly reading images from URLs is " - "deprecated since %(since)s and will no longer be supported " - "%(removal)s. Please open the URL for reading and pass the " - "result to Pillow, e.g. with " - "``np.array(PIL.Image.open(urllib.request.urlopen(url)))``.") - # hide imports to speed initial import on systems with slow linkers - from urllib import request - ssl_ctx = mpl._get_ssl_context() - if ssl_ctx is None: - _log.debug( - "Could not get certifi ssl context, https may not work." - ) - with request.urlopen(fname, context=ssl_ctx) as response: - import io - try: - response.seek(0) - except (AttributeError, io.UnsupportedOperation): - response = io.BytesIO(response.read()) - return imread(response, format=ext) + if isinstance(fname, str) and len(parse.urlparse(fname).scheme) > 1: + # Pillow doesn't handle URLs directly. + raise ValueError( + "Please open the URL for reading and pass the " + "result to Pillow, e.g. with " + "``np.array(PIL.Image.open(urllib.request.urlopen(url)))``." + ) with img_open(fname) as image: return (_pil_png_to_float_array(image) if isinstance(image, PIL.PngImagePlugin.PngImageFile) else diff --git a/lib/matplotlib/tests/test_image.py b/lib/matplotlib/tests/test_image.py index e8e90b768085..a5a6a0a6a33f 100644 --- a/lib/matplotlib/tests/test_image.py +++ b/lib/matplotlib/tests/test_image.py @@ -13,7 +13,7 @@ import matplotlib as mpl from matplotlib import ( - _api, colors, image as mimage, patches, pyplot as plt, style, rcParams) + colors, image as mimage, patches, pyplot as plt, style, rcParams) from matplotlib.image import (AxesImage, BboxImage, FigureImage, NonUniformImage, PcolorImage) from matplotlib.testing.decorators import check_figures_equal, image_comparison @@ -720,7 +720,7 @@ def test_load_from_url(): url = ('file:' + ('///' if sys.platform == 'win32' else '') + path.resolve().as_posix()) - with _api.suppress_matplotlib_deprecation_warning(): + with pytest.raises(ValueError, match="Please open the URL"): plt.imread(url) with urllib.request.urlopen(url) as file: plt.imread(file) @@ -1139,13 +1139,6 @@ def test_exact_vmin(): assert np.all(from_image == direct_computation) -@pytest.mark.network -@pytest.mark.flaky -def test_https_imread_smoketest(): - with _api.suppress_matplotlib_deprecation_warning(): - v = mimage.imread('https://matplotlib.org/1.5.0/_static/logo2.png') - - # A basic ndarray subclass that implements a quantity # It does not implement an entire unit system or all quantity math. # There is just enough implemented to test handling of ndarray From fd8f8f83b1aa84aa7ccddc90563412cf716b8999 Mon Sep 17 00:00:00 2001 From: Greg Lucas Date: Sat, 21 May 2022 19:51:36 -0600 Subject: [PATCH 09/11] MNT: Remove network marker from pytest There are no tests that need network access, so remove the marker. --- lib/matplotlib/testing/conftest.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/matplotlib/testing/conftest.py b/lib/matplotlib/testing/conftest.py index 01e60fea05e4..b535390a1b80 100644 --- a/lib/matplotlib/testing/conftest.py +++ b/lib/matplotlib/testing/conftest.py @@ -17,7 +17,6 @@ def pytest_configure(config): "style: Set alternate Matplotlib style temporarily (deprecated)."), ("markers", "baseline_images: Compare output against references."), ("markers", "pytz: Tests that require pytz to be installed."), - ("markers", "network: Tests that reach out to the network."), ("filterwarnings", "error"), ("filterwarnings", "ignore:.*The py23 module has been deprecated:DeprecationWarning"), From 25f4059568eed5a748e2b887cad4a180f7ab2416 Mon Sep 17 00:00:00 2001 From: Greg Lucas Date: Sat, 21 May 2022 19:59:43 -0600 Subject: [PATCH 10/11] MNT: Remove deprecated widget properties --- .../next_api_changes/removals/23XXX-GL.rst | 6 ++++ lib/matplotlib/widgets.py | 28 ------------------- 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/doc/api/next_api_changes/removals/23XXX-GL.rst b/doc/api/next_api_changes/removals/23XXX-GL.rst index 57f28f3550cc..2bb0f092eec7 100644 --- a/doc/api/next_api_changes/removals/23XXX-GL.rst +++ b/doc/api/next_api_changes/removals/23XXX-GL.rst @@ -34,3 +34,9 @@ Passing a URL to `~.pyplot.imread()` has been removed. Please open the URL for reading and directly use the Pillow API (``PIL.Image.open(urllib.request.urlopen(url))``, or ``PIL.Image.open(io.BytesIO(requests.get(url).content))``) instead. + +Deprecated properties of widgets have been removed +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +These include ``cids``, ``cnt``, ``observers``, ``change_observers``, +and ``submit_observers``. diff --git a/lib/matplotlib/widgets.py b/lib/matplotlib/widgets.py index cf3471c923f0..dcd5d7309668 100644 --- a/lib/matplotlib/widgets.py +++ b/lib/matplotlib/widgets.py @@ -111,8 +111,6 @@ class AxesWidget(Widget): If False, the widget does not respond to events. """ - cids = _api.deprecated("3.4")(property(lambda self: self._cids)) - def __init__(self, ax): self.ax = ax self.canvas = ax.figure.canvas @@ -153,11 +151,6 @@ class Button(AxesWidget): The color of the button when hovering. """ - cnt = _api.deprecated("3.4")(property( # Not real, but close enough. - lambda self: len(self._observers.callbacks['clicked']))) - observers = _api.deprecated("3.4")(property( - lambda self: self._observers.callbacks['clicked'])) - def __init__(self, ax, label, image=None, color='0.85', hovercolor='0.95'): """ @@ -323,11 +316,6 @@ class Slider(SliderBase): Slider value. """ - cnt = _api.deprecated("3.4")(property( # Not real, but close enough. - lambda self: len(self._observers.callbacks['changed']))) - observers = _api.deprecated("3.4")(property( - lambda self: self._observers.callbacks['changed'])) - def __init__(self, ax, label, valmin, valmax, valinit=0.5, valfmt=None, closedmin=True, closedmax=True, slidermin=None, slidermax=None, dragging=True, valstep=None, @@ -989,11 +977,6 @@ class CheckButtons(AxesWidget): each box, but have ``set_visible(False)`` when its box is not checked. """ - cnt = _api.deprecated("3.4")(property( # Not real, but close enough. - lambda self: len(self._observers.callbacks['clicked']))) - observers = _api.deprecated("3.4")(property( - lambda self: self._observers.callbacks['clicked'])) - def __init__(self, ax, labels, actives=None): """ Add check buttons to `matplotlib.axes.Axes` instance *ax*. @@ -1141,12 +1124,6 @@ class TextBox(AxesWidget): The color of the text box when hovering. """ - cnt = _api.deprecated("3.4")(property( # Not real, but close enough. - lambda self: sum(len(d) for d in self._observers.callbacks.values()))) - change_observers = _api.deprecated("3.4")(property( - lambda self: self._observers.callbacks['change'])) - submit_observers = _api.deprecated("3.4")(property( - lambda self: self._observers.callbacks['submit'])) DIST_FROM_LEFT = _api.deprecate_privatize_attribute("3.5") def __init__(self, ax, label, initial='', @@ -1477,11 +1454,6 @@ def __init__(self, ax, labels, active=0, activecolor='blue'): self._observers = cbook.CallbackRegistry(signals=["clicked"]) - cnt = _api.deprecated("3.4")(property( # Not real, but close enough. - lambda self: len(self._observers.callbacks['clicked']))) - observers = _api.deprecated("3.4")(property( - lambda self: self._observers.callbacks['clicked'])) - def _clicked(self, event): if self.ignore(event) or event.button != 1 or event.inaxes != self.ax: return From 461a1271da8a7af9c83222c625ccbdb425d70fc1 Mon Sep 17 00:00:00 2001 From: Greg Lucas Date: Sat, 21 May 2022 20:22:39 -0600 Subject: [PATCH 11/11] MNT: Remove properties and methods from Subplot This follows the deprecation period. --- .../removals/{23XXX-GL.rst => 23093-GL.rst} | 8 +++ lib/matplotlib/axes/_subplots.py | 58 +------------------ 2 files changed, 10 insertions(+), 56 deletions(-) rename doc/api/next_api_changes/removals/{23XXX-GL.rst => 23093-GL.rst} (80%) diff --git a/doc/api/next_api_changes/removals/23XXX-GL.rst b/doc/api/next_api_changes/removals/23093-GL.rst similarity index 80% rename from doc/api/next_api_changes/removals/23XXX-GL.rst rename to doc/api/next_api_changes/removals/23093-GL.rst index 2bb0f092eec7..a155c29830cf 100644 --- a/doc/api/next_api_changes/removals/23XXX-GL.rst +++ b/doc/api/next_api_changes/removals/23093-GL.rst @@ -40,3 +40,11 @@ Deprecated properties of widgets have been removed These include ``cids``, ``cnt``, ``observers``, ``change_observers``, and ``submit_observers``. + +Removal of methods and properties of ``Subplot`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +These include ``get_geometry()``, ``change_geometry()``, ``figbox``, +``numRows``, ``numCols``, ``update_params()``, ``is_first_row()``, +``is_first_col()``, ``is_last_row()``, ``is_last_col()``. The subplotspec +contains this information and can be used to replace these methods and properties. diff --git a/lib/matplotlib/axes/_subplots.py b/lib/matplotlib/axes/_subplots.py index 18faf2e9d086..b31388a2154f 100644 --- a/lib/matplotlib/axes/_subplots.py +++ b/lib/matplotlib/axes/_subplots.py @@ -1,7 +1,7 @@ import matplotlib as mpl -from matplotlib import _api, cbook +from matplotlib import cbook from matplotlib.axes._axes import Axes -from matplotlib.gridspec import GridSpec, SubplotSpec +from matplotlib.gridspec import SubplotSpec class SubplotBase: @@ -35,22 +35,6 @@ def __init__(self, fig, *args, **kwargs): # This will also update the axes position. self.set_subplotspec(SubplotSpec._from_subplot_args(fig, args)) - @_api.deprecated( - "3.4", alternative="get_subplotspec", - addendum="(get_subplotspec returns a SubplotSpec instance.)") - def get_geometry(self): - """Get the subplot geometry, e.g., (2, 2, 3).""" - rows, cols, num1, num2 = self.get_subplotspec().get_geometry() - return rows, cols, num1 + 1 # for compatibility - - @_api.deprecated("3.4", alternative="set_subplotspec") - def change_geometry(self, numrows, numcols, num): - """Change subplot geometry, e.g., from (1, 1, 1) to (2, 2, 3).""" - self._subplotspec = GridSpec(numrows, numcols, - figure=self.figure)[num - 1] - self.update_params() - self.set_position(self.figbox) - def get_subplotspec(self): """Return the `.SubplotSpec` instance associated with the subplot.""" return self._subplotspec @@ -64,44 +48,6 @@ def get_gridspec(self): """Return the `.GridSpec` instance associated with the subplot.""" return self._subplotspec.get_gridspec() - @_api.deprecated( - "3.4", alternative="get_position()") - @property - def figbox(self): - return self.get_position() - - @_api.deprecated("3.4", alternative="get_gridspec().nrows") - @property - def numRows(self): - return self.get_gridspec().nrows - - @_api.deprecated("3.4", alternative="get_gridspec().ncols") - @property - def numCols(self): - return self.get_gridspec().ncols - - @_api.deprecated("3.4") - def update_params(self): - """Update the subplot position from ``self.figure.subplotpars``.""" - # Now a no-op, as figbox/numRows/numCols are (deprecated) auto-updating - # properties. - - @_api.deprecated("3.4", alternative="ax.get_subplotspec().is_first_row()") - def is_first_row(self): - return self.get_subplotspec().rowspan.start == 0 - - @_api.deprecated("3.4", alternative="ax.get_subplotspec().is_last_row()") - def is_last_row(self): - return self.get_subplotspec().rowspan.stop == self.get_gridspec().nrows - - @_api.deprecated("3.4", alternative="ax.get_subplotspec().is_first_col()") - def is_first_col(self): - return self.get_subplotspec().colspan.start == 0 - - @_api.deprecated("3.4", alternative="ax.get_subplotspec().is_last_col()") - def is_last_col(self): - return self.get_subplotspec().colspan.stop == self.get_gridspec().ncols - def label_outer(self): """ Only show "outer" labels and tick labels. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy