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

Commit80b7c57

Browse files
committed
MNT: move creating interal ScalarMappable to where it is used
This make it clearer that we only need this in one of the code pathsand avoids creating the un-used ScalarMappable in the png savefig codepath.
1 parentd66f959 commit80b7c57

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎lib/matplotlib/image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,8 +1553,6 @@ def imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None,
15531553
else:
15541554
# Don't bother creating an image; this avoids rounding errors on the
15551555
# size when dividing and then multiplying by dpi.
1556-
sm=cm.ScalarMappable(cmap=cmap)
1557-
sm.set_clim(vmin,vmax)
15581556
iforiginisNone:
15591557
origin=mpl.rcParams["image.origin"]
15601558
iforigin=="lower":
@@ -1567,6 +1565,8 @@ def imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None,
15671565
# as is, saving a few operations.
15681566
rgba=arr
15691567
else:
1568+
sm=cm.ScalarMappable(cmap=cmap)
1569+
sm.set_clim(vmin,vmax)
15701570
rgba=sm.to_rgba(arr,bytes=True)
15711571
ifpil_kwargsisNone:
15721572
pil_kwargs= {}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp