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

Skip to content

Commit d6caaf4

Browse files
committed
multivar_colorbar: fix for docs
1 parent 13ff336 commit d6caaf4

3 files changed

Lines changed: 80 additions & 38 deletions

File tree

doc/api/figure_api.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ Annotating
256256
:nosignatures:
257257

258258
SubFigure.colorbar
259-
SubFigure.bivar_colorbar
259+
SubFigure.colorbar_bivar
260+
SubFigure.colorbar_multivar
260261
SubFigure.legend
261262
SubFigure.text
262263
SubFigure.suptitle

lib/matplotlib/colorbar.py

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,7 @@ class BivarColorbar:
14171417
r"""
14181418
Draw a bivariate colorbar in an existing Axes.
14191419
1420-
Typically, bivariate colorbars are created using `.Figure.bivar_colorbar`
1420+
Typically, bivariate colorbars are created using `.Figure.colorbar_bivar`
14211421
and associated with `.ColorizingArtist`\s (such as an
14221422
`.AxesImage` generated via `~.axes.Axes.imshow`).
14231423
@@ -1444,9 +1444,6 @@ def __init__(
14441444
mappable : `.ColorizingArtist`
14451445
The mappable whose colormap and norm will be used.
14461446
1447-
To show the colors versus index instead of on a 0-1 scale, set the
1448-
mappable's norm to ``colors.NoNorm()``.
1449-
14501447
alpha : float
14511448
The colorbars transparency between 0 (transparent) and 1 (opaque).
14521449
@@ -1608,36 +1605,6 @@ def xaxis(self):
16081605
def yaxis(self):
16091606
return self.ax.yaxis
16101607

1611-
"""
1612-
def _y_limits_changed(self, ax=None):
1613-
if not self._allow_change_limits:
1614-
ylim = self.ax.get_ylim()
1615-
if self.colorizer.norm.norms[0].vmin != ylim[0]:
1616-
self.colorizer.norm.norms[0].vmin = ylim[0]
1617-
if self.colorizer.norm.norms[0].vmax != ylim[1]:
1618-
self.colorizer.norm.norms[0].vmax = ylim[1]
1619-
1620-
def _x_limits_changed(self, ax=None):
1621-
if not self._allow_change_limits:
1622-
xlim = self.ax.get_xlim()
1623-
if self.colorizer.norm.norms[1].vmin != xlim[0]:
1624-
self.colorizer.norm.norms[1].vmin = xlim[0]
1625-
if self.colorizer.norm.norms[1].vmax != xlim[1]:
1626-
self.colorizer.norm.norms[1].vmax = xlim[1]
1627-
"""
1628-
"""
1629-
def _update_limits(self, ax=None):
1630-
if not self._allow_change_limits:
1631-
ylim = self.ax.get_ylim()
1632-
xlim = self.ax.get_xlim()
1633-
if (self.colorizer.norm.norms[0].vmin != ylim[0] or
1634-
self.colorizer.norm.norms[0].vmax != ylim[1] or
1635-
self.colorizer.norm.norms[1].vmin != xlim[0] or
1636-
self.colorizer.norm.norms[1].vmax != xlim[1]):
1637-
raise ValueError("Changing the limits of this axis must be done "
1638-
"using the norm attached to the bivariate colorbar.")
1639-
"""
1640-
16411608
def update_normals(self, mappable=None):
16421609
self.set_alpha(self.mappable.get_alpha())
16431610
#self._draw_all()
@@ -1721,7 +1688,48 @@ def _cbar_cla(self):
17211688

17221689

17231690
class MultivarColorbar(Sequence):
1691+
r"""
1692+
Draw a multivariate colorbar in existing Axes.
1693+
1694+
Typically, multivariate colorbars are created using `.Figure.colorbar_multivar`
1695+
and associated with `.ColorizingArtist`\s (such as an
1696+
`.AxesImage` generated via `~.axes.Axes.imshow`).
1697+
1698+
MultivarColorbar is iterable, and the constituent Colorbar objects can be accessed
1699+
by index.
1700+
"""
1701+
17241702
def __init__(self, axes, mappable=None, **kwargs):
1703+
"""
1704+
Parameters
1705+
----------
1706+
axes : list of `~matplotlib.axes.Axes`
1707+
The `~.axes.Axes` instances in which the colorbars are drawn.
1708+
1709+
mappable : `.ColorizingArtist`
1710+
The mappable whose colormap and norm will be used.
1711+
1712+
alpha : float
1713+
The colorbars transparency between 0 (transparent) and 1 (opaque).
1714+
1715+
location : None or {'left', 'right', 'top', 'bottom'}
1716+
Set the multivariate colorbars's location
1717+
1718+
Other Parameters
1719+
----------------
1720+
orientation : None or {'vertical', 'horizontal'}
1721+
If None, use the value determined by *location*. If both
1722+
*orientation* and *location* are None then defaults to 'vertical'.
1723+
1724+
ticklocation : {'auto', 'left', 'right', 'top', 'bottom'}
1725+
The location of the colorbar ticks. The *ticklocation* must match
1726+
*orientation*. For example, a horizontal colorbar can only have ticks
1727+
at the top or the bottom. If 'auto', the ticks will be the same as
1728+
*location*, so a colorbar to the left will have ticks to the left. If
1729+
*location* is None, the ticks will be at the bottom for a horizontal
1730+
colorbar and at the right for a vertical.
1731+
"""
1732+
17251733
if isinstance(mappable, mpl.colorizer.Colorizer):
17261734
mappable = mcolorizer.ColorizingArtist(mappable)
17271735

@@ -2167,7 +2175,7 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15,
21672175
def make_bivar_axes(parents, location=None, fraction=0.15,
21682176
shrink=1.0, aspect=1.0, **kwargs):
21692177
"""
2170-
Create an `~.axes.Axes` suitable for a bivar_colorbar.
2178+
Create an `~.axes.Axes` suitable for a bivariate colorbar.
21712179
21722180
The Axes is placed in the figure of the *parents* Axes, by resizing and
21732181
repositioning *parents*.

lib/matplotlib/figure.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,8 +1337,8 @@ def colorbar_bivar(
13371337
Parameters
13381338
----------
13391339
mappable
1340-
The `matplotlib.colorizer.ColorizingArtist` (i.e., `.AxesImage`,
1341-
`.ContourSet`, etc.) described by this bivariate colorbar.
1340+
The `matplotlib.colorizer.ColorizingArtist` (i.e., `.AxesImage`
1341+
etc.) described by this bivariate colorbar.
13421342
This argument is mandatory for the `.Figure.colorbar_bivar` method
13431343
but optional for the`.pyplot.colorbar_bivar` function, which sets
13441344
the default to the current image.
@@ -1424,6 +1424,39 @@ def colorbar_bivar(
14241424
def colorbar_multivar(
14251425
self, mappable, *, caxes=None, ax=None,
14261426
n_major=-1, **kwargs):
1427+
"""
1428+
Add a bivariate colorbar to a plot.
1429+
1430+
Parameters
1431+
----------
1432+
mappable
1433+
The `matplotlib.colorizer.ColorizingArtist` (i.e., `.AxesImage`
1434+
etc.) described by this multivariate colorbar.
1435+
This argument is mandatory for the `.Figure.colorbar_multivar` method
1436+
but optional for the`.pyplot.colorbar_multivar` function, which sets
1437+
the default to the current image.
1438+
1439+
caxes : `~matplotlib.axes.Axes`, optional
1440+
Axes into which the colorbar will be drawn. If `None`, then new
1441+
Axes are created and the space for it will be stolen from the Axes(s)
1442+
specified in *ax*.
1443+
1444+
ax : `~matplotlib.axes.Axes` or iterable or `numpy.ndarray` of Axes, optional
1445+
The one or more parent Axes from which space for a new colorbar Axes
1446+
will be stolen. This parameter is only used if *cax* is not set.
1447+
1448+
Defaults to the Axes that contains the mappable used to create the
1449+
colorbar.
1450+
1451+
Returns
1452+
-------
1453+
multivariate_colorbar : `~matplotlib.colorbar.MultivarColorbar`
1454+
1455+
Other Parameters
1456+
----------------
1457+
%(_make_multivar_axes_kw_doc)s
1458+
1459+
"""
14271460

14281461
if isinstance(mappable, mpl.colorizer.Colorizer):
14291462
mappable = mcolorizer.ColorizingArtist(mappable)

0 commit comments

Comments
 (0)