Home  >  Q&A  >  body text

Why can't the color of each point be set in color in python's scatter?

plt.scatter(x=rw.x_value,y=rw.y_value,c=point_number,colormap=plt.cm.Blues,gecolors='none',s=15)

where point_number refers to a series of points, and then uses range() to generate a list of numbers, and uses color mapping, but when running, an error ValueError: Invalid RGBA argument: 0
is used in python3
I would like to ask how the color parameter in scatter can be set for each point

巴扎黑巴扎黑2710 days ago1250

reply all(1)I'll reply

  • 大家讲道理

    大家讲道理2017-05-18 11:04:35

    下面是文档中对scatter的参数c的说明:
    c : color, sequence, or sequence of color, optional, default: ‘b’
    c can be a single color format string, or a sequence of color specifications of length N, or a sequence of N numbers to be mapped to colors using the cmap and norm specified via kwargs (see below). Note that c should not be a single numeric RGB or RGBA sequence because that is indistinguishable from an array of values to be colormapped. c can be a 2-D array in which the rows are RGB or RGBA, however, including the case of a single row to specify the same color for all points.

    可见可以传入一个序列(list之类的)

    reply
    0
  • Cancelreply