Matplotlib vline label parameter not showing

后端 未结 3 1821
再見小時候
再見小時候 2021-02-20 03:32

I want to label my vertical lines with matplotlib\'s .vline command, but for some reason the label parameter doesn\'t do anything/show anything on the final plot. Does anyone kn

3条回答
  •  -上瘾入骨i
    2021-02-20 03:57

    The label keyword is displayed in the legend. You need create the legend explicitly to see the label in the plot:

    plt.vlines([1,2,3], 0, 1, label='test')
    plt.legend()
    

提交回复
热议问题