加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

使用python中的matplotlib进行绘图分析数据

发布时间:2020-12-17 17:19:56 所属栏目:Python 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 快速绘图 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 # coding=gbk '' ' Created on Jul 12 , 2014 py

以下代码由PHP站长网 52php.cn收集自互联网

现在PHP站长网小编把它分享给大家,仅供参考


快速绘图

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# coding=gbk
'' '
Created on Jul 12 , 2014
python 科学计算学习:numpy快速处理数据测试
@author : 皮皮
'' '
import string
import matplotlib.pyplot as plt?
import numpy as np
?
if __name__ == '__main__' :???
???? file = open(E:machine_learningdatasetshousing_datahousing_data_ages.txt, 'r' )
???? linesList = file.readlines()
#???? print(linesList)
???? linesList = [line.strip().split(,) for line in linesList]
???? file.close()???
???? print(linesList:)
???? print(linesList)
#???? years = [string.atof(x[ ]) for x in linesList]
???? years = [x[ ] for x in linesList]
???? print(years)
???? price = [x[ 1 ] for x in linesList]
???? print(price)
???? plt.plot(years,price, 'b*' )#,label=$cos(x^ 2 )$)
???? plt.plot(years, 'r' )
???? plt.xlabel(years(+ 2000 ))
???? plt.ylabel(housing average price(* 2000 yuan))
???? plt.ylim( , 15 )
???? plt.title( 'line_regression & gradient decrease' )
???? plt.legend()
???? plt.show()
?

以上内容由PHP站长网【52php.cn】收集整理供大家参考研究

如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读