Closed
Description
Bug report
Bug summary
2-D array color does not work in plt.plot() while working as intended in plt.scatter(). A 2-D array is recommended by matplotlib itself by this warning:
"'c' argument looks like a single numeric RGB or RGBA sequence, which should be avoided as value-mapping will have precedence in case its length matches with 'x' & 'y'. Please use a 2-D array with a single row if you really want to specify the same RGB or RGBA value for all points."
Code for reproduction
import matplotlib.pyplot as plt
import numpy as np
color_rgb = np.array([[0.1,0.2,0.3]])
color_rgba = np.array([[0.1,0.2,0.3,0.4]])
plt.scatter([1,2],[1,2],c=color_rgb) # working
plt.plot([1,2],[1,2],c=color_rgb) # not working
plt.scatter([1,2],[1,2],c=color_rgba) # works fine
plt.plot([1,2],[1,2],c=color_rgba) # NOT working
plt.show()
Actual outcome
Invalid RGBA argument: array([[0.1, 0.2, 0.3, 0.4]])
Matplotlib version
- Operating system: Win 10 1909
- Matplotlib version: 3.1.3 (from anaconda, pkgs/main)
- Matplotlib backend (
print(matplotlib.get_backend())
): module://ipykernel.pylab.backend_inline - Python version: 3.8.1