plt.text(50,8,s = “均方根误差:”+str(rmse))matplotlib可视化篇—共享坐标轴

参考

作图美化

  1. # 作图美化
  2. %config InlineBackend.figure_format = 'retina'
  3. %matplotlib inline
  4. import seaborn as sns
  5. sns.set(font= "Kaiti",style="ticks",font_scale=1.0)
  6. import matplotlib
  7. import matplotlib.pyplot as plt
  8. matplotlib.rcParams['axes.unicode_minus']=False # 解决坐标轴的负号显示问题

简单示例

  1. plt.figure(figsize=(21, 9))
  2. plt.plot(df.values[243:334, 0], label='2018')
  3. plt.plot(df.values[608:699, 0], label='2019')
  4. plt.plot(df.values[974:1065, 0], label='2020')
  5. plt.ylabel('总有功功率(kw)')
  6. plt.xlabel('时间(日)')
  7. plt.title('9月到12月每日总有功功率')
  8. plt.text(50,8,s = "均方根误差:"+str(rmse))
  9. plt.legend(loc="upper right")
  10. plt.show()

image.png

  1. plt.figure(figsize=(15, 10))
  2. plt.subplot(3, 1, 1)
  3. plt.plot(df.values[243:334, 0])
  4. plt.title('2018每日总有功功率', y=0.75, loc='right')
  5. plt.subplot(3, 1, 2)
  6. plt.plot(df.values[608:699, 0])
  7. plt.title('2019每日总有功功率', y=0.75, loc='right')
  8. plt.subplot(3, 1, 3)
  9. plt.plot(df.values[974:1065, 0])
  10. plt.title('2020每日总有功功率', y=0.75, loc='right')
  11. plt.show()

image.png

plt.text()函数解析(参考