Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Reorganize colorbar docstrings. #17780

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
Jun 28, 2020
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
5 changes: 5 additions & 0 deletions doc/api/api_changes_3.4/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ Deprecations
``dpi_cor`` property of `.FancyArrowPatch`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This parameter is considered internal and deprecated.

Colorbar docstrings
~~~~~~~~~~~~~~~~~~~
The following globals in :mod:`matplotlib.colorbar` are deprecated:
``colorbar_doc``, ``colormap_kw_doc``, ``make_axes_kw_doc``.
28 changes: 10 additions & 18 deletions lib/matplotlib/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@
axes' anchor will be unchanged.
Defaults to (1.0, 0.5) if vertical; (0.5, 0.0) if horizontal.
"""
make_axes_kw_doc = _make_axes_param_doc + _make_axes_other_param_doc

colormap_kw_doc = """
_colormap_kw_doc = """

============ ====================================================
Property Description
Expand Down Expand Up @@ -149,18 +148,9 @@

"""

colorbar_doc = """

docstring.interpd.update(colorbar_doc="""
Add a colorbar to a plot.

Function signatures for the :mod:`~matplotlib.pyplot` interface; all
but the first are also method signatures for the `~.Figure.colorbar` method::

colorbar(**kwargs)
colorbar(mappable, **kwargs)
colorbar(mappable, cax=cax, **kwargs)
colorbar(mappable, ax=ax, **kwargs)

Parameters
----------
mappable
Expand All @@ -179,9 +169,8 @@
Axes into which the colorbar will be drawn.

ax : `~matplotlib.axes.Axes`, list of Axes, optional
Parent axes from which space for a new colorbar axes will be stolen.
If a list of axes is given they will all be resized to make room for the
colorbar axes.
One or more parent axes from which space for a new colorbar axes will be
stolen, if *cax* is None. This has no effect if *cax* is set.

use_gridspec : bool, optional
If *cax* is ``None``, a new *cax* is created as an instance of Axes. If
Expand All @@ -198,6 +187,7 @@
Additional keyword arguments are of two kinds:

axes properties:
%s
%s
colorbar properties:
%s
Expand Down Expand Up @@ -225,10 +215,12 @@
However this has negative consequences in other circumstances, e.g. with
semi-transparent images (alpha < 1) and colorbar extensions; therefore, this
workaround is not used by default (see issue #1188).
""" % (_make_axes_param_doc, _make_axes_other_param_doc, _colormap_kw_doc))

""" % (make_axes_kw_doc, colormap_kw_doc)

docstring.interpd.update(colorbar_doc=colorbar_doc)
# Deprecated since 3.4.
colorbar_doc = docstring.interpd.params["colorbar_doc"]
colormap_kw_doc = _colormap_kw_doc
make_axes_kw_doc = _make_axes_param_doc + _make_axes_other_param_doc


def _set_ticks_on_axis_warn(*args, **kw):
Expand Down
7 changes: 1 addition & 6 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -2315,12 +2315,7 @@ def savefig(self, fname, *, transparent=None, **kwargs):

@docstring.dedent_interpd
def colorbar(self, mappable, cax=None, ax=None, use_gridspec=True, **kw):
"""
Create a colorbar for a ScalarMappable instance, *mappable*.

Documentation for the pyplot thin wrapper:
%(colorbar_doc)s
"""
"""%(colorbar_doc)s"""
if ax is None:
ax = self.gca()

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2172,6 +2172,7 @@ def _setup_pyplot_info_docstrings():
## Plotting part 1: manually generated functions and wrappers ##


@_copy_docstring_and_deprecators(Figure.colorbar)
def colorbar(mappable=None, cax=None, ax=None, **kw):
if mappable is None:
mappable = gci()
Expand All @@ -2184,7 +2185,6 @@ def colorbar(mappable=None, cax=None, ax=None, **kw):
ax = gca()
ret = gcf().colorbar(mappable, cax=cax, ax=ax, **kw)
return ret
colorbar.__doc__ = matplotlib.colorbar.colorbar_doc


def clim(vmin=None, vmax=None):
Expand Down