How to put text outside python plots?

前端 未结 2 1527
春和景丽
春和景丽 2021-02-02 08:14

I am plotting two time series and computing varies indices for them.

How to write these indices for these plots outside the plot using annotation or t

2条回答
  •  故里飘歌
    2021-02-02 09:07

    Looks like the text is there but it lies outside of the figure boundary. Use subplots_adjust() to make room for the text:

    import matplotlib.pyplot as plt
    
    textstr = 'NSE=%.2f\nRMSE=%.2f\n'%(1, 2)
    plt.xlim(2002, 2008)
    plt.ylim(0, 4500)
    # print textstr
    plt.text(2000, 2000, textstr, fontsize=14)
    plt.grid(True)
    plt.subplots_adjust(left=0.25)
    plt.show()
    

提交回复
热议问题