python画折线图的程序
作者:Imcy 时间:2021-07-04 18:08:20
前做PPT要用到折线图,嫌弃EXCEL自带的看上去不好看,就用python写了一个画折线图的程序。
import matplotlib.pyplot as plt
x=[1,2,3,4,5,6]
y1=[35000,85000,120000]
y2=[45000,85000,100000]
y3=[25000,65000,90000]
point1=180180
point2=200000
plt.rcParams['font.sans-serif'] = ['SimHei'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus'] = False #用来正常显示负号
plt.scatter(x[5],point1,marker='o')
plt.scatter(x[5],point2,marker='o')
plt.plot(x[:3],y1,label='计划值PV',linewidth = 2)
plt.plot(x[:3],y2,'g--',label='挣值EV',linewidth = 2)
plt.plot(x[:3],y3,'r-.',label='实际成本AC',linewidth = 2)
plt.ylabel('美元')
plt.xlabel('月')
plt.annotate('EAC:%d'%point1, xy = (6, point1), xytext=(5.5*0.9, point1*0.9),
arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=.2")) #添加注释,即85%处的标记。这里包括了指定箭头样式。
plt.annotate('BAC:%d'%point2, xy = (6, point2), xytext=(5*0.9, point2*0.9),
arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=.2")) #添加注释,即85%处的标记。这里包括了指定箭头样式
plt.title('项目3个月后的挣值示意图')
plt.legend()
plt.show()
结果图:
来源:https://blog.csdn.net/u013948010/article/details/78452765
标签:python,折线图
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python使用遗传算法解决最大流问题
2023-02-19 10:49:57
![](https://img.aspxhome.com/file/2023/3/84943_0s.jpg)
解决pycharm每次新建项目都要重新安装一些第三方库的问题
2023-02-22 23:08:22
![](https://img.aspxhome.com/file/2023/0/110230_0s.jpg)
Python爬虫工程师面试问题总结
2023-06-10 13:23:20
Python光学仿真学习衍射算法初步理解
2021-01-07 13:54:46
![](https://img.aspxhome.com/file/2023/3/110373_0s.png)
Python和php通信乱码问题解决方法
2023-03-04 14:50:43
Python线性网络实现分类糖尿病病例
2022-03-13 11:23:25
![](https://img.aspxhome.com/file/2023/9/70179_0s.png)
Python装饰器用法实例分析
2023-02-22 12:05:49
中国传统色彩名录
2007-11-29 18:36:00
提升Python运行速度的5个小技巧
2021-07-28 20:25:24
如何基于Python实现电子邮件的发送
2022-03-16 11:49:16
![](https://img.aspxhome.com/file/2023/3/69433_0s.png)
在Python的struct模块中进行数据格式转换的方法
2021-09-26 14:24:40
![](https://img.aspxhome.com/file/2023/6/101176_0s.jpg)
如何优化下面这段代码?
2010-01-23 11:30:00
Python asyncio异步编程简单实现示例
2023-09-23 15:27:52
![](https://img.aspxhome.com/file/2023/9/68419_0s.jpg)
python开发中range()函数用法实例分析
2021-05-08 12:53:26
详解Python之unittest单元测试代码
2022-04-15 02:28:12
![](https://img.aspxhome.com/file/2023/0/130560_0s.png)
网站防止采集方法全攻略
2007-09-05 19:57:00
联邦学习神经网络FedAvg算法实现
2022-05-25 12:06:34
![](https://img.aspxhome.com/file/2023/0/130640_0s.png)
prototype.js常用函数及其用法
2007-11-21 20:47:00
详解Python列表解析式的使用方法
2022-06-30 10:10:15
OpenCV4.1.0+VS2017环境配置的方法步骤
2022-11-21 18:22:38
![](https://img.aspxhome.com/file/2023/4/110404_0s.jpg)