You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DOC: Added blurb for colorizer objects in what's new for 3.10 (#29478)
* Added blurb for colorizer objects in what's new for 3.10
* Update doc/users/prev_whats_new/whats_new_3.10.0.rst
Co-authored-by: Tim Hoffmann <[email protected]>
* Text updates to the colorizer blurb from QuLogic
Co-authored-by: Elliott Sales de Andrade <[email protected]>
---------
Co-authored-by: Tim Hoffmann <[email protected]>
Co-authored-by: Elliott Sales de Andrade <[email protected]>
`matplotlib.colorizer.Colorizer` encapsulates the data-to-color pipeline. It makes reuse of colormapping easier, e.g. across multiple images. Plotting methods that support *norm* and *cmap* keyword arguments now also accept a *colorizer* keyword argument.
299
+
300
+
In the following example the norm and cmap are changed on multiple plots simultaneously:
301
+
302
+
303
+
.. plot::
304
+
:include-source: true
305
+
:alt: Example use of a matplotlib.colorizer.Colorizer object
306
+
307
+
import matplotlib.pyplot as plt
308
+
import matplotlib as mpl
309
+
import numpy as np
310
+
311
+
x = np.linspace(-2, 2, 50)[np.newaxis, :]
312
+
y = np.linspace(-2, 2, 50)[:, np.newaxis]
313
+
im_0 = 1 * np.exp( - (x**2 + y**2 - x * y))
314
+
im_1 = 2 * np.exp( - (x**2 + y**2 + x * y))
315
+
316
+
colorizer = mpl.colorizer.Colorizer()
317
+
fig, axes = plt.subplots(1, 2, figsize=(6, 2))
318
+
cim_0 = axes[0].imshow(im_0, colorizer=colorizer)
319
+
fig.colorbar(cim_0)
320
+
cim_1 = axes[1].imshow(im_1, colorizer=colorizer)
321
+
fig.colorbar(cim_1)
322
+
323
+
colorizer.vmin = 0.5
324
+
colorizer.vmax = 2
325
+
colorizer.cmap = 'RdBu'
326
+
327
+
All plotting methods that use a data-to-color pipeline now create a colorizer object if one is not provided. This can be re-used by subsequent artists such that they will share a single data-to-color pipeline:
328
+
329
+
.. plot::
330
+
:include-source: true
331
+
:alt: Example of how artists that share a ``colorizer`` have coupled colormaps
0 commit comments