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

Commit928e58c

Browse files
committed
Error on bad input to hexbin extents
1 parentd3892d5 commit928e58c

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

‎lib/matplotlib/axes/_axes.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4999,6 +4999,10 @@ def reduce_C_function(C: array) -> float
49994999
ty=np.log10(ty)
50005000
ifextentisnotNone:
50015001
xmin,xmax,ymin,ymax=extent
5002+
ifxmin>xmax:
5003+
raiseValueError("In extent, xmax must be greater than xmin")
5004+
ifymin>ymax:
5005+
raiseValueError("In extent, ymax must be greater than ymin")
50025006
else:
50035007
xmin,xmax= (tx.min(),tx.max())iflen(x)else (0,1)
50045008
ymin,ymax= (ty.min(),ty.max())iflen(y)else (0,1)

‎lib/matplotlib/tests/test_axes.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,18 @@ def test_hexbin_extent():
962962
ax.hexbin("x","y",extent=[.1,.3,.6,.7],data=data)
963963

964964

965+
deftest_hexbin_bad_extents():
966+
fig,ax=plt.subplots()
967+
data= (np.arange(2000)/2000).reshape((2,1000))
968+
x,y=data
969+
970+
withpytest.raises(ValueError,match="In extent, xmax must be greater than xmin"):
971+
ax.hexbin(x,y,extent=(1,0,0,1))
972+
973+
withpytest.raises(ValueError,match="In extent, ymax must be greater than ymin"):
974+
ax.hexbin(x,y,extent=(0,1,1,0))
975+
976+
965977
@image_comparison(['hexbin_empty.png'],remove_text=True)
966978
deftest_hexbin_empty():
967979
# From #3886: creating hexbin from empty dataset raises ValueError

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp