pyplot combine multiple line labels in legend

前端 未结 6 2136
鱼传尺愫
鱼传尺愫 2020-12-29 07:00

I have data that results in multiple lines being plotted, I want to give these lines a single label in my legend. I think this can be better demonstrated using the example b

6条回答
  •  悲哀的现实
    2020-12-29 07:37

    I would do this trick:

    for i in range(len(a)):
      plt.plot(a[i,::2].T, a[i, 1::2].T, 'r', label='data_a' if i==0 else None)
    

提交回复
热议问题