Skip to content

Document how to make colorbars "without" a ScalarMappable. #13171

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 13, 2019
Merged
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
9 changes: 7 additions & 2 deletions lib/matplotlib/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,17 @@
Parameters
----------
mappable
The `~matplotlib.cm.ScalarMappable` (i.e., `~matplotlib.image.Image`,
`~matplotlib.contour.ContourSet`, etc.) to which the colorbar applies.
The `matplotlib.cm.ScalarMappable` (i.e., `~matplotlib.image.Image`,
`~matplotlib.contour.ContourSet`, etc.) described by this colorbar.
This argument is mandatory for the `.Figure.colorbar` method but optional
for the `.pyplot.colorbar` function, which sets the default to the current
image.

Note that one can create a `ScalarMappable` "on-the-fly" to generate
colorbars not attached to a previously drawn artist, e.g. ::

fig.colorbar(cm.ScalarMappable(norm=norm, cmap=cmap, ax=ax))

cax : :class:`~matplotlib.axes.Axes` object, optional
Axes into which the colorbar will be drawn.

Expand Down