Skip to content

Expire colorbar-related deprecations. #22081

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions doc/api/next_api_changes/removals/22081-AL.rst
Original file line number Diff line number Diff line change
@@ -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``.
43 changes: 0 additions & 43 deletions lib/matplotlib/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__.
Expand Down Expand Up @@ -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)
10 changes: 1 addition & 9 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down