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

Skip to content

Commit 952ca40

Browse files
committed
chained exceptions so that exceptions raised by mcolors.to_rgba_array() are not hidden.
1 parent 7b5ff33 commit 952ca40

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4213,23 +4213,23 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
42134213
# NB: remember that a single color is also acceptable.
42144214
# Besides *colors* will be an empty array if c == 'none'.
42154215
valid_shape = False
4216-
raise ValueError
4217-
except ValueError:
4218-
if not valid_shape: # but at least one conversion succeeded.
42194216
raise ValueError(
42204217
"'c' argument has {nc} elements, which is not "
42214218
"acceptable for use with 'x' with size {xs}, "
42224219
"'y' with size {ys}."
42234220
.format(nc=n_elem, xs=x.size, ys=y.size)
42244221
)
4225-
# Both the mapping *and* the RGBA conversion failed: pretty
4226-
# severe failure => one may appreciate a verbose feedback.
4227-
raise ValueError(
4228-
"'c' argument must either be valid as mpl color(s) "
4229-
"or as numbers to be mapped to colors. "
4230-
"Here c = {}." # <- beware, could be long depending on c.
4231-
.format(c)
4232-
)
4222+
except Exception as e:
4223+
if valid_shape:
4224+
# Both the mapping *and* the RGBA conversion failed: pretty
4225+
# severe failure => one may appreciate a verbose feedback.
4226+
raise ValueError(
4227+
"'c' argument must either be valid as mpl color(s) "
4228+
"or as numbers to be mapped to colors. "
4229+
"Here c = {}." # <- beware, could be long depending on c.
4230+
.format(c)
4231+
) from e
4232+
raise e
42334233
else:
42344234
colors = None # use cmap, norm after collection is created
42354235

0 commit comments

Comments
 (0)