How to remove outline of circle marker when using pyplot.plot in matplotlib

前端 未结 3 1852
失恋的感觉
失恋的感觉 2020-12-25 11:25

I\'m producing a scatter plot using pyplot.plot (instead of scatter - I\'m having difficulties with the colormap)

I am plotting using the \'o\' marker to get a circl

相关标签:
3条回答
  • 2020-12-25 12:10

    This is outlined in matplotlib.axes.Axes.scatter documentation found at https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.scatter.html

    It specifies that line edge colors for scatter plot markers can be set with

     edgecolors : color or sequence of color, optional, default: ‘face’
     The edge color of the marker. Possible values:
    
     - ‘face’: The edge color will always be the same as the face color.
     - ‘none’: No patch boundary will be drawn.
     - A matplotib color.
    
     For non-filled markers, the edgecolors kwarg is ignored and forced to ‘face’ internally.
    

    The width of the line edges can be specified with

    `linewidths` : scalar or array_like, optional, default: None
    
    The linewidth of the marker edges.
    
    Note: The default edgecolors is ‘face’.
    

    You may want to change this as well. If None, defaults to rcParams lines.linewidth.

    0 讨论(0)
  • 2020-12-25 12:21

    From the pyplot API docs:

    markeredgecolor or mec any matplotlib color

    Example:

    In [1]: import matplotlib.pyplot as plt
    
    In [2]: import numpy as np
    
    In [3]: x = np.linspace(0,1,11)
    
    In [4]: y = x * x
    
    In [5]: plt.plot(x,y,'o',color="red", ms=15, mec="red")
    Out[5]: [<matplotlib.lines.Line2D at 0x34e1cd0>]
    
    In [6]: plt.show()
    

    Yields: Figure

    Is that what you're looking for?

    0 讨论(0)
  • 2020-12-25 12:27

    To remove the outline of a marker, and adjust its color, use markeredgewidth (aka mew), and markeredgecolor (aka mec) respectively.

    Using this as a guide:

    import numpy as np
    import matplotlib.pyplot as plt
    
    x = np.arange(0, 5, 0.1)
    y = np.sin(x)
    
    plt.plot(x,
             y,
             color='blue',
             marker='o',
             fillstyle='full',
             markeredgecolor='red',
             markeredgewidth=0.0)
    

    This produces:

    As you notice, even though the marker edge color is set, because the width of it is set to zero it doesn't show up.

    0 讨论(0)
提交回复
热议问题