small scatter plot markers in matplotlib are always black

后端 未结 4 470
后悔当初
后悔当初 2021-02-02 05:47

I\'m trying to use matplotlib to make a scatter plot with very small gray points. Because of the point density, the points need to be small. The problem is that the scatter()

4条回答
  •  太阳男子
    2021-02-02 06:14

    The absolute simplest answer to your question is: use the color parameter instead of the c parameter to set the color of the whole marker.

    It's easy to see the difference when you compare the results:

    from matplotlib import pyplot as plt
    
    plt.scatter([1,2,3], [3,1,2], c='0.8')  # marker not all gray
    
    plt.scatter([1,2,3], [3,1,2], color='0.8')  # marker all gray
    

    Details: For your simple use case where you just want to make your whole marker be the same shade of gray color, you really shouldn't have to worry about things like face color vs edge color, and whether your marker is defined as all edges or some edges and some fill. Instead, just use the color parameter and know that your whole marker will be set to the single color that you specify!

提交回复
热议问题