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

Commit156a0f6

Browse files
authored
Merge pull request#20503 from meeseeksmachine/auto-backport-of-pr-20488-on-v3.4.x
Backport PR#20488 on branch v3.4.x (FIX: Include 0 when checking lognorm vmin)
2 parentsdf9fa06 +dcb3708 commit156a0f6

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

‎lib/matplotlib/image.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,9 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
534534
# we have re-set the vmin/vmax to account for small errors
535535
# that may have moved input values in/out of range
536536
s_vmin,s_vmax=vrange
537-
ifisinstance(self.norm,mcolors.LogNorm):
538-
ifs_vmin<0:
539-
s_vmin=max(s_vmin,np.finfo(scaled_dtype).eps)
537+
ifisinstance(self.norm,mcolors.LogNorm)ands_vmin<=0:
538+
# Don't give 0 or negative values to LogNorm
539+
s_vmin=np.finfo(scaled_dtype).eps
540540
withcbook._setattr_cm(self.norm,
541541
vmin=s_vmin,
542542
vmax=s_vmax,

‎lib/matplotlib/tests/test_image.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,23 +1213,24 @@ def test_imshow_quantitynd():
12131213
fig.canvas.draw()
12141214

12151215

1216+
@pytest.mark.parametrize('x', [-1,1])
12161217
@check_figures_equal(extensions=['png'])
1217-
deftest_huge_range_log(fig_test,fig_ref):
1218-
data=np.full((5,5),-1,dtype=np.float64)
1218+
deftest_huge_range_log(fig_test,fig_ref,x):
1219+
# parametrize over bad lognorm -1 values and large range 1 -> 1e20
1220+
data=np.full((5,5),x,dtype=np.float64)
12191221
data[0:2, :]=1E20
12201222

12211223
ax=fig_test.subplots()
1222-
im=ax.imshow(data,norm=colors.LogNorm(vmin=100,vmax=data.max()),
1223-
interpolation='nearest',cmap='viridis')
1224+
ax.imshow(data,norm=colors.LogNorm(vmin=1,vmax=data.max()),
1225+
interpolation='nearest',cmap='viridis')
12241226

1225-
data=np.full((5,5),-1,dtype=np.float64)
1227+
data=np.full((5,5),x,dtype=np.float64)
12261228
data[0:2, :]=1000
12271229

1228-
cmap=copy(plt.get_cmap('viridis'))
1229-
cmap.set_under('w')
12301230
ax=fig_ref.subplots()
1231-
im=ax.imshow(data,norm=colors.Normalize(vmin=100,vmax=data.max()),
1232-
interpolation='nearest',cmap=cmap)
1231+
cmap=plt.get_cmap('viridis').with_extremes(under='w')
1232+
ax.imshow(data,norm=colors.Normalize(vmin=1,vmax=data.max()),
1233+
interpolation='nearest',cmap=cmap)
12331234

12341235

12351236
@check_figures_equal()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp