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

Commit7647550

Browse files
authored
Merge pull request#18042 from QuLogic/scatter-size
scatter: Raise if unexpected type of `s` argument.
2 parents0a83b9c +bda5766 commit7647550

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

‎lib/matplotlib/axes/_axes.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4447,8 +4447,12 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
44474447
s= (20ifrcParams['_internal.classic_mode']else
44484448
rcParams['lines.markersize']**2.0)
44494449
s=np.ma.ravel(s)
4450-
iflen(s)notin (1,x.size):
4451-
raiseValueError("s must be a scalar, or the same size as x and y")
4450+
if (len(s)notin (1,x.size)or
4451+
(notnp.issubdtype(s.dtype,np.floating)and
4452+
notnp.issubdtype(s.dtype,np.integer))):
4453+
raiseValueError(
4454+
"s must be a scalar, "
4455+
"or float array-like with the same size as x and y")
44524456

44534457
c,colors,edgecolors= \
44544458
self._parse_scatter_color_args(

‎lib/matplotlib/tests/test_axes.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,10 +1909,12 @@ def test_scatter_unfilled(self):
19091909

19101910
deftest_scatter_size_arg_size(self):
19111911
x=np.arange(4)
1912-
withpytest.raises(ValueError):
1912+
withpytest.raises(ValueError,match='same size as x and y'):
19131913
plt.scatter(x,x,x[1:])
1914-
withpytest.raises(ValueError):
1914+
withpytest.raises(ValueError,match='same size as x and y'):
19151915
plt.scatter(x[1:],x[1:],x)
1916+
withpytest.raises(ValueError,match='float array-like'):
1917+
plt.scatter(x,x,'foo')
19161918

19171919
@check_figures_equal(extensions=["png"])
19181920
deftest_scatter_invalid_color(self,fig_test,fig_ref):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp