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

Skip to content

Commit b1b0006

Browse files
committed
2-D array RGB and RGBA values not understood in plt.plot()
Issue #18411 #18411
1 parent 5584ba7 commit b1b0006

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/matplotlib/colors.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,10 @@ def _to_rgba_no_colorcycle(c, alpha=None):
265265
f"Value must be within 0-1 range")
266266
return c, c, c, alpha if alpha is not None else 1.
267267
raise ValueError(f"Invalid RGBA argument: {orig_c!r}")
268+
# turn 2-D array into 1-D array
269+
if isinstance(c, np.ndarray):
270+
if c.ndim == 2 and c.shape[0] == 1:
271+
c = c.reshape((-1))
268272
# tuple color.
269273
if not np.iterable(c):
270274
raise ValueError(f"Invalid RGBA argument: {orig_c!r}")

0 commit comments

Comments
 (0)