Heim  >  Fragen und Antworten  >  Hauptteil

Warum kann die Farbe jedes Punkts in Pythons Streuung nicht farblich festgelegt werden?

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

Wobei sich point_number auf eine Reihe von Punkten bezieht und dann range() verwendet, um eine Liste von Zahlen zu generieren, und Farbzuordnung verwendet, aber beim Ausführen wird ein Fehler gemeldet. ValueError: Ungültiges RGBA-Argument: 0
Ich verwende Python3
I möchte fragen: Mal sehen, wie der Farbparameter in der Streuung für jeden Punkt eingestellt werden kann

巴扎黑巴扎黑2710 Tage vor1256

Antworte allen(1)Ich werde antworten

  • 大家讲道理

    大家讲道理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之类的)

    Antwort
    0
  • StornierenAntwort