Matplotlib legends in subplot

前端 未结 3 1753
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-25 10:30

I would like to put legends inside each one of the subplots below. I\'ve tried with plt.legend but it didn\'t work.

Any suggestions?

Thanks in advance :-)

3条回答
  •  生来不讨喜
    2020-12-25 10:43

    This should work:

    ax1.plot(xtr, color='r', label='HHZ 1')
    ax1.legend(loc="upper right")
    ax2.plot(xtr, color='r', label='HHN')
    ax2.legend(loc="upper right")
    ax3.plot(xtr, color='r', label='HHE')
    ax3.legend(loc="upper right")
    

提交回复
热议问题