python数据分析与展示(四)
2017-08-04 21:59
155 查看
实践:
课程的示例,引力波的绘制:
资源文件:http://python123.io/dv/grawave.html
课程的示例,引力波的绘制:
资源文件:http://python123.io/dv/grawave.html
import numpy as np import matplotlib.pyplot as plt from scipy.io import wavfile #波形文件 #速率 数据 rate_h,hstrain= wavfile.read(r"H1_Strain.wav","rb") # print(rate_h,hstrain) #print(len(hstrain)) #print(hstrain.shape) rate_l, lstrain = wavfile.read(r'L1_Strain.wav', 'rb') #读取出来 转置 #理论模型 reftime,ref_H1 = np.genfromtxt('wf_template.txt').transpose() #计算出时间间隔 htime_interval = 1/rate_h ltime_interval = 1 / rate_l #计算出单位时间的数据量 htime_len = hstrain.shape[0]/rate_h # 时间坐标原点在中心 绘制时间与数据一一对应 htime = np.arange(-htime_len/2,htime_len/2,htime_interval) # print(len(htime)) ltime_len = lstrain.shape[0] / rate_l ltime = np.arange(-ltime_len/2,ltime_len/2,ltime_interval) #绘制H1 Strain fig = plt.figure(figsize=(12,6)) plth = fig.add_subplot(221) plth.plot(htime,hstrain,'y') plth.set_xlabel("时间(s)",fontproperties="Kaiti") plth.set_ylabel("H1 Strain") plth.set_title("探测器数据1",fontproperties="Kaiti",fontsize=20) #绘制 L1 Strain pltl = fig.add_subplot(222) pltl.plot(ltime,lstrain,'g') pltl.set_xlabel("时间(s)",fontproperties="Kaiti") pltl.set_ylabel("L1 Strain") pltl.set_title("探测数据2",fontproperties="Kaiti",fontsize=20) #绘制标准数据 pltref = fig.add_subplot(212) pltref.plot(reftime,ref_H1) pltref.set_xlabel("时间(s)",fontproperties="Kaiti") pltref.set_ylabel("Template") pltref.set_title("标准数据",fontproperties="Kaiti",fontsize=20) fig.tight_layout() plt.show()
自己编写的例子
从 中国国家统计局获取分省经济增长数据绘制折线图 网址:http://www.stats.gov.cn/tjsj/ 代码:
import numpy as np import matplotlib.pyplot as plt import matplotlib matplotlib.rcParams['font.family']='SimHei' # 地区 city_labels=['北京市','天津市','河北省','河北省','内蒙古自治区','辽宁省','吉林省'] #获取数据 data = np.loadtxt('分省月度数据.csv',delimiter=',',dtype=float) #获取数据形状 print(data.shape) #抽取城市,因为城市过多,不利于分析,抽取7组 city_data_style=data.shape[0] num=0 for city in range(7): plt.plot(data[city][::-1]) plt.ylabel("较去年同期增长百分比(%)",fontproperties="Kaiti",fontsize=17) plt.xlabel("月份",fontproperties="Kaiti",fontsize=17) plt.legend(city_labels,loc=0,ncol=3,) plt.xticks([0,1,2,3,4,5,6,7,8,9,10,11,], ['16年7月','16年8月','16年9月','16年10月','16年11月','16年12月','17年1月','17年2月','17年3月','17年4月','17年5月','17年6月',]) plt.title("16年7月-17年6月,分省同比增长数据显示图",fontproperties="Kaiti",fontsize=20,) plt.show()
相关文章推荐
- Python数据分析与展示(2)——Numpy数据存取与函数
- python数据分析与展示(三)
- python 抓取数据,pandas进行数据分析并可视化展示
- Python-数据分析与展示学习笔记(一)
- Python数据分析与展示(6)——Pandas数据特征分析
- Python数据分析与展示(1)——NumPy库入门
- python数据分析与展示(一)
- Python-数据分析与展示学习笔记(二)
- Python-数据分析与展示学习笔记(三)
- python数据分析及展示(三)
- Python数据分析与展示 | 【第一周】数据分析之表示 课后作业
- Python数据分析与展示(3)——Matplotlib库入门
- python数据分析及展示(一)
- python数据分析及展示(二)
- Python数据分析与展示 | 【第二周】数据分析之展示 课后作业
- Python分析处理本机各项数据并以chartdirector图形化展示
- python数据分析实战之泰坦尼克号统计
- python数据分析系列教程——NumPy全解
- 数据挖掘之推荐分析--python实现
- 对Python进行数据分析_关于Package的安装问题