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

Commit33f3526

Browse files
committed
FIX: Include 0 when checking lognorm vmin
Change vmin check to less than or equal to 0 rather than strictlyless than.
1 parent2a3037f commit33f3526

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
@@ -532,9 +532,9 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
532532
# we have re-set the vmin/vmax to account for small errors
533533
# that may have moved input values in/out of range
534534
s_vmin,s_vmax=vrange
535-
ifisinstance(self.norm,mcolors.LogNorm):
536-
ifs_vmin<0:
537-
s_vmin=max(s_vmin,np.finfo(scaled_dtype).eps)
535+
ifisinstance(self.norm,mcolors.LogNorm)ands_vmin<=0:
536+
# Don't give 0 or negative values to LogNorm
537+
s_vmin=np.finfo(scaled_dtype).eps
538538
withcbook._setattr_cm(self.norm,
539539
vmin=s_vmin,
540540
vmax=s_vmax,

‎lib/matplotlib/tests/test_image.py‎

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

12351235

1236+
@pytest.mark.parametrize('x', [-1,1])
12361237
@check_figures_equal(extensions=['png'])
1237-
deftest_huge_range_log(fig_test,fig_ref):
1238-
data=np.full((5,5),-1,dtype=np.float64)
1238+
deftest_huge_range_log(fig_test,fig_ref,x):
1239+
# parametrize over bad lognorm -1 values and large range 1 -> 1e20
1240+
data=np.full((5,5),x,dtype=np.float64)
12391241
data[0:2, :]=1E20
12401242

12411243
ax=fig_test.subplots()
1242-
im=ax.imshow(data,norm=colors.LogNorm(vmin=100,vmax=data.max()),
1243-
interpolation='nearest',cmap='viridis')
1244+
ax.imshow(data,norm=colors.LogNorm(vmin=1,vmax=data.max()),
1245+
interpolation='nearest',cmap='viridis')
12441246

1245-
data=np.full((5,5),-1,dtype=np.float64)
1247+
data=np.full((5,5),x,dtype=np.float64)
12461248
data[0:2, :]=1000
12471249

1248-
cmap=copy(plt.get_cmap('viridis'))
1249-
cmap.set_under('w')
12501250
ax=fig_ref.subplots()
1251-
im=ax.imshow(data,norm=colors.Normalize(vmin=100,vmax=data.max()),
1252-
interpolation='nearest',cmap=cmap)
1251+
cmap=plt.get_cmap('viridis').with_extremes(under='w')
1252+
ax.imshow(data,norm=colors.Normalize(vmin=1,vmax=data.max()),
1253+
interpolation='nearest',cmap=cmap)
12531254

12541255

12551256
@check_figures_equal()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp