代码之家  ›  专栏  ›  技术社区  ›  max

Matplotlib-散点图点周围的边框

  •  31
  • max  · 技术社区  · 7 年前

    this tutorial

    我想使用Matplotlib创建一个散点图,其中的点在内部着色,但有一个黑色边框,例如:

    photo

    enter image description here

    colors = ['black', 'blue', 'purple', 'yellow', 'white', 'red', 'lime', 'cyan', 'orange', 'gray']
    for i in range(len(colors)):
        x = reduced_data_rpca[:, 0][digits.target == i]
        y = reduced_data_rpca[:, 1][digits.target == i]
        plt.scatter(x, y, c=colors[i])
    plt.legend(digits.target_names, bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
    plt.xlabel('First Principal Component')
    plt.ylabel('Second Principal Component')
    plt.title("PCA Scatter Plot")
    plt.show()
    

    我试着调整一下风格,但没用。

    1 回复  |  直到 7 年前
        1
  •  9
  •   rth    7 年前

    In the official documentation

    edgecolors:颜色或颜色顺序,可选,默认值:无

    如果没有,则默认为face

    如果为“无”,则不会绘制面片边界。

    面对内心。

    plt.scatter(x, y, c=colors[i],edgecolors='black')