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
`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