python如何添加文字_在python中向图例添加文本

本文介绍如何在Python的matplotlib库中为图表添加文字,包括在图例中添加详细说明,以及创建文本框,确保在缩放时位置不变。示例代码展示了如何绘制散点图、线图,并在图例下方添加复杂的数学公式和额外信息,以及设置图表的各种元素,如标题、坐标轴标签、网格线等。
摘要由CSDN通过智能技术生成

我正试图在传说中添加一些文字。是关于盒子里的文字。另一种解决方案是,文本框位于图例下方,放大图形时不会移动。plt.scatter(stageheight,discharge,color='b',label='measured data')

plt.plot(stageheight_hecras,discharge_hecras,'y^',label='modeled with HEC-RAS')

plt.plot(stageheight_masked,discharge_predicted,'r-',label='regression line measured data')

plt.plot(stageheight_hecras,discharge_predicted_hecras,'g-',label='regression line HEC-RAS')

plt.plot(stageheight_masked,upper,'r--',label='15% error measured data')

plt.plot(stageheight_masked,lower,'r--')

plt.plot(stageheight_hecras,upper_hecras,'g--',label='30% error HEC-RAS')

plt.plot(stageheight_hecras,lower_hecras,'g--')

plt.fill_between(stageheight_masked,upper,lower,facecolor='red',edgecolor='red',alpha=0.5

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值