Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit306c8de

Browse files
trygvradtimhoffmQuLogic
authored
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.rstCo-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>* Text updates to the colorizer blurb from QuLogicCo-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>---------Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
1 parent597af1c commit306c8de

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

‎doc/users/prev_whats_new/whats_new_3.10.0.rst

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,62 @@ the ``set_data`` method, enabling e.g. resampling
292292
fig.savefig("after.png")
293293
294294
295+
``matplotlib.colorizer.Colorizer`` as container for ``norm`` and ``cmap``
296+
-------------------------------------------------------------------------
297+
298+
`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
332+
333+
import matplotlib.pyplot as plt
334+
import matplotlib as mpl
335+
import numpy as np
336+
337+
x = np.linspace(-2, 2, 50)[np.newaxis, :]
338+
y = np.linspace(-2, 2, 50)[:, np.newaxis]
339+
im_0 = 1 * np.exp( - (x**2 + y**2 - x * y))
340+
im_1 = 2 * np.exp( - (x**2 + y**2 + x * y))
341+
342+
fig, axes = plt.subplots(1, 2, figsize=(6, 2))
343+
344+
cim_0 = axes[0].imshow(im_0, cmap='RdBu', vmin=0.5, vmax=2)
345+
fig.colorbar(cim_0)
346+
cim_1 = axes[1].imshow(im_1, colorizer=cim_0.colorizer)
347+
fig.colorbar(cim_1)
348+
349+
cim_1.cmap = 'rainbow'
350+
295351
3D plotting improvements
296352
========================
297353

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp