From 7058cd83f309001c8843e550fbdba36cc4adca1b Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 2 Jan 2022 16:11:57 +0100 Subject: [PATCH] Expire colorbar-related deprecations. --- .../next_api_changes/removals/22081-AL.rst | 11 +++++ lib/matplotlib/colorbar.py | 43 ------------------- lib/matplotlib/figure.py | 10 +---- 3 files changed, 12 insertions(+), 52 deletions(-) create mode 100644 doc/api/next_api_changes/removals/22081-AL.rst diff --git a/doc/api/next_api_changes/removals/22081-AL.rst b/doc/api/next_api_changes/removals/22081-AL.rst new file mode 100644 index 000000000000..6f971f3df352 --- /dev/null +++ b/doc/api/next_api_changes/removals/22081-AL.rst @@ -0,0 +1,11 @@ +colorbar defaults to stealing space from the mappable's axes rather than the current axes +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Pass ``ax=plt.gca()`` to restore the previous behavior. + +Removal of deprecated ``colorbar`` APIs +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The following deprecated :mod:`.colorbar` APIs have been removed: +``ColorbarPatch`` and ``colorbar_factory`` (use `.Colorbar` instead); +``colorbar_doc``, ``colorbar_kw_doc``, ``make_axes_kw_doc``. diff --git a/lib/matplotlib/colorbar.py b/lib/matplotlib/colorbar.py index b8da91c05109..f5f0c962e1fd 100644 --- a/lib/matplotlib/colorbar.py +++ b/lib/matplotlib/colorbar.py @@ -194,16 +194,6 @@ _colormap_kw_doc)) -@_api.caching_module_getattr # module-level deprecations -class __getattr__: - colorbar_doc = _api.deprecated("3.4", obj_type="")(property( - lambda self: docstring.interpd.params["colorbar_doc"])) - colorbar_kw_doc = _api.deprecated("3.4", obj_type="")(property( - lambda self: _colormap_kw_doc)) - make_axes_kw_doc = _api.deprecated("3.4", obj_type="")(property( - lambda self: _make_axes_param_doc + _make_axes_other_param_doc)) - - def _set_ticks_on_axis_warn(*args, **kwargs): # a top level function which gets put in at the axes' # set_xticks and set_yticks by Colorbar.__init__. @@ -1587,36 +1577,3 @@ def make_axes_gridspec(parent, *, location=None, orientation=None, aspect=aspect0, pad=pad) return cax, kwargs - - -@_api.deprecated("3.4", alternative="Colorbar") -class ColorbarPatch(Colorbar): - pass - - -@_api.deprecated("3.4", alternative="Colorbar") -def colorbar_factory(cax, mappable, **kwargs): - """ - Create a colorbar on the given axes for the given mappable. - - .. note:: - This is a low-level function to turn an existing axes into a colorbar - axes. Typically, you'll want to use `~.Figure.colorbar` instead, which - automatically handles creation and placement of a suitable axes as - well. - - Parameters - ---------- - cax : `~matplotlib.axes.Axes` - The `~.axes.Axes` to turn into a colorbar. - mappable : `~matplotlib.cm.ScalarMappable` - The mappable to be described by the colorbar. - **kwargs - Keyword arguments are passed to the respective colorbar class. - - Returns - ------- - `.Colorbar` - The created colorbar instance. - """ - return Colorbar(cax, mappable, **kwargs) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 7b05331b2e84..d08edb963068 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -1129,15 +1129,7 @@ def colorbar( self, mappable, cax=None, ax=None, use_gridspec=True, **kwargs): """%(colorbar_doc)s""" if ax is None: - ax = self.gca() - if (hasattr(mappable, "axes") and ax is not mappable.axes - and cax is None): - _api.warn_deprecated( - "3.4", message="Starting from Matplotlib 3.6, colorbar() " - "will steal space from the mappable's axes, rather than " - "from the current axes, to place the colorbar. To " - "silence this warning, explicitly pass the 'ax' argument " - "to colorbar().") + ax = getattr(mappable, "axes", self.gca()) # Store the value of gca so that we can set it back later on. if cax is None: