Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Update to docs with regards to colorbar and colorizer#30112
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
""" | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
from matplotlibimport colors | ||
import matplotlibas mpl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think we don't explicitly support or encourage chained usage of subpackages, I.e. mpl.this.that
@@ -31,12 +32,13 @@ | |||
fig, axs = plt.subplots(2, 2) | |||
fig.suptitle('Multiple images') | |||
# create a single norm to be shared across all images | |||
norm = colors.Normalize(vmin=np.min(datasets), vmax=np.max(datasets)) | |||
# create a single norm and colorizer to be shared across all images |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
# create asingle norm and colorizer to be shared across all images | |
# create acolorizer with a predefined norm to be shared across all images |
# - `matplotlib.colors.Normalize` | ||
# - `matplotlib.cm.ScalarMappable.set_cmap` | ||
# - `matplotlib.cbook.CallbackRegistry.connect` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think connect is removed as well
A `~.Figure.colorbar` needs a "mappable" (`matplotlib.colorizer.ColorizingArtist`) | ||
object (typically, an image) which contains a colorizer | ||
(`matplotlib.colorizer.Colorizer`) that holds the data-to-color pipeline (norm and | ||
colormap). In order to create a colorbar without an attached image, one can instead | ||
use a `.ColorizingArtist` with no associated data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think you can be more straightforward. ColorizingArtist is the base class for everything that "can be colormapped". Directly instruct to create the base class and pass it to colorbar. This the detour "typically subclasses with data, like image, but you can create without data" is not needed for the context of creating a standalone colorbar.
Uh oh!
There was an error while loading.Please reload this page.
PR summary
This PR updateshttps://matplotlib.org/stable/gallery/images_contours_and_fields/multi_image.html andhttps://matplotlib.org/stable/users/explain/colors/colorbar_only.html in light of the interoduction of
colorizer.Colorizer
andcolorizer.ColorizingArtist
(#28658).It also updates the docs of
colorbar.Colorbar
to referencecolorizer.ColorizingArtist
instead ofcm.ScalarMappable
See#30008 for a related discussion.
PR checklist