matplotlib c argument

1
plt.scatter(x_values, y_values, c=(0, 0, 0.8), edgecolor='none', s=40)

c1

Warn
‘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.
Answer from stackoverflow
In the latest version of matplotlib (3.0.3), argument ‘c’ should be a 2-D array. If the length of ‘c’ matches with the length of ‘x’ and ‘y’, the color of each point corresponds to the element of the ‘c’. If you want to make every point show the same color, ‘c’ should be a 2-D array with a single row, such as c=np.array([0.5, 0.5, 0.5]). https://stackoverflow.com/questions/55109716/c-argument-looks-like-a-single-numeric-rgb-or-rgba-sequence

原因是新的matplotlib版本里,argument c 应该是2维数组。

我试过改成c=np.array([0, 0, 0.8]),还是不行。

最终解决方法为:

把 ’c‘ argument 改成 color

1
plt.scatter(x_values, y_values, color=(0, 0, 0.8), edgecolor='none', s=40)