Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3c58e2a

Browse files
authored
Merge pull request #15883 from anntzer/scatter-unsized
Improve error when passing 0d array to scatter().
2 parents f8a9a49 + eb38d25 commit 3c58e2a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import collections.abc
21
import functools
32
import itertools
43
import logging
@@ -4204,7 +4203,7 @@ def _parse_scatter_color_args(c, edgecolors, kwargs, xsize,
42044203
else get_next_color_func())
42054204
c_is_string_or_strings = (
42064205
isinstance(c, str)
4207-
or (isinstance(c, collections.abc.Iterable) and len(c) > 0
4206+
or (np.iterable(c) and len(c) > 0
42084207
and isinstance(cbook.safe_first_element(c), str)))
42094208

42104209
def invalid_shape_exception(csize, xsize):
@@ -4238,7 +4237,7 @@ def invalid_shape_exception(csize, xsize):
42384237
if not c_is_mapped:
42394238
try: # Is 'c' acceptable as PathCollection facecolors?
42404239
colors = mcolors.to_rgba_array(c)
4241-
except ValueError:
4240+
except (TypeError, ValueError):
42424241
if not valid_shape:
42434242
raise invalid_shape_exception(c.size, xsize)
42444243
# Both the mapping *and* the RGBA conversion failed: pretty

0 commit comments

Comments
 (0)