Description
Bug report
Bug summary
Scatter docs say that in order to provide a single RGB/RGBA color for all scatter elements, it is required to pass a 2D array with a single row for c
argument input:
If you want to specify the same RGB or RGBA value for all points, use a 2-D array with a single row. Otherwise, value- matching will have precedence in case of a size matching with x and y.
When x/y shape is 3 and RGB is passed as a 2D array with a single row (e.g. c=[[1, 0.5, 0.05]]
), or when x/y shape is 4 and RGBA is passed as a 2D array with a single row, the plot elements have several different colors (taken from the default colormap?) while all should have the same color. The problem occurs for both plt.scatter
and ax.scatter
calls, and also if c
input is provided as a numpy array of shape (1,3) for RGB or (1,4) for RGBA instead of a nested list.
Code for reproduction
import matplotlib.pyplot as plt
plt.scatter(range(3), range(3), c=[[1, 0.5, 0.05]])
#alternatively, for RGBA scenario
plt.scatter(range(4), range(4), c=[[1, 0.5, 0.05, 1]])
Expected outcome
All points have the same color: RGB (1, 0.5, 0.05).
Matplotlib version
- Operating system: Linux
- Matplotlib version: 3.2.1
- Matplotlib backend (
print(matplotlib.get_backend())
): agg - Python version: 3.7.3
Matplotlib installed through pip