报错信息
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 the color keyword-argument or provide a 2-D array with a single row if you intend to specify the same RGB or RGBA value for all points.
python-matplotlib模块使用scatter
的参数c
设置绘制点的颜色
c使用RGB颜色模式自定义颜色时,会报错
eg:
x_values = [1, 2, 3, 4, 5]
y_values = [1, 4, 9, 16, 25]
fig, ax = plt.subplots()
ax.scatter(x_values, y_values,s=100,c=(0,0.8,0.4))
解决方法
将c
改为color
就不会显示报错了
ax.scatter(x_values, y_values,s=100,color=(0,0.8,0.4))