Are there really only 4 Matplotlib Line Styles?

前端 未结 1 1356
小鲜肉
小鲜肉 2020-12-11 00:58

I\'ve been looking for new line styles in matplotlib, and the only line styles available are [\"-\", \"--\", \"-.\", \":\",]. (The style options [\'\', \' \', \'None\',] don

相关标签:
1条回答
  • 2020-12-11 01:42

    You can use the dashes kwarg to set custom dash styles.

    From the docs:

    Set the dash sequence, sequence of dashes with on off ink in points. If seq is empty or if seq = (None, None), the linestyle will be set to solid.

    Here's some examples based on a few of your suggestions. Obviously there are many more ways you could customise this.

    import matplotlib.pyplot as plt
    
    fig,ax = plt.subplots(1)
    
    # 3 dots then space
    ax.plot(range(10), range(10),     dashes=[3,6,3,6,3,18],  lw=3,c='b')
    
    # dash dash dot
    ax.plot(range(10), range(0,20,2), dashes=[12,6,12,6,3,6], lw=3,c='r')
    
    # dash dot dot
    ax.plot(range(10), range(0,30,3), dashes=[12,6,3,6,3,6],  lw=3,c='g')
    

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