如何将文本放在图形外部
- 论坛
- 如何将文本放在图形外部
4 浏览
如何将文本放在图形外部
我正在绘制两个时间序列并计算它们的各种指标。如何在Python中使用annotation
或text
将这些指标写在图表之外?
下面是我的代码:
import matplotlib.pyplot as plt obs_graph=plt.plot(obs_df['cms'], '-r', label='Observed') plt.legend(loc='best') plt.hold(True) sim_graph=plt.plot(sim_df['cms'], '-g', label="Simulated") plt.legend(loc='best') plt.ylabel('Daily Discharge (m^3/s)') plt.xlabel('Year') plt.title('Observed vs Simulated Daily Discharge') textstr = 'NSE=%.2f\nRMSE=%.2f\n'%(NSE, RMSE) # print textstr plt.text(2000, 2000, textstr, fontsize=14) plt.grid(True) plt.show()
我想将textstr
打印在图表之外。这是当前的图表: