Python数据分析与展示——Matplotlib
Matplotlib:数据可视化库
import matplotlib.pyplot as plt
内容:
代码托管:https://github.com/ve-loo/python/blob/master/matplotlib.ipynb
电脑文件夹C:\Users\asus-1\Desktop\2020learn\Numpy1中的matplotlib.ipynb
一、pyplot的plot函数、中文显示、文本显示、子绘图区域
1.pyplot的plot()函数
2.pyplot的中文显示
3.pyplot的文本显示
5.pyplot的子绘图区域
二、基础绘图函数
1、饼图
plt.pie()
2.直方图
plt.hist()
3.极坐标图
4.散点图
三、引力波的绘制
实例2:引力波的绘制
- 什么是引力波?
物理学中,引力波是因为时空弯曲对外以辐射形式传播的能量.
爱因斯坦基于广义相对论预言了引力波的存在.
数据源:http://python123.io/dv/grawave.html
import numpy as np #科学计算库numpy
import matplotlib.pyplot as plt #绘图所用的pyplot
from scipy.io import wavfile #读取波形文件的库
rate_h, hstrain = wavfile.read(r"C:/Users/asus-1/Desktop/2020learn/Numpy1/H1_Strain.wav",“rb”) #wavfile可用来读取音频文件,在字符串前添加r表示原始的字符串
rate_l, lstrain = wavfile.read(r"C:/Users/asus-1/Desktop/2020learn/Numpy1/L1_Strain.wav",“rb”) # 速率rate,数值strain
#reftime, ref_H1 = np.genfromtxt(‘GW150914_4_NR_waveform_template.txt’).transpace() #reftime是时间序列,ref_H1是信号的数据
reftime, ref_H1 = np.genfromtxt(‘C:/Users/asus-1/Desktop/2020learn/Numpy1/wf_template.txt’).transpose() #使用python123.io下载文件
htime_interval = 1/rate_h
ltime_interval = 1/rate_l
fig = plt.figure(figsize = (12, 6)) # 丢失信号起始点 创建12*6的绘图空间
htime_len = hstrain.shape[0] / rate_h
htime = np.arange(-htime_len/2, htime_len/2, htime_interval)
plth =fig.add_subplot(221)
plth.plot(htime,hstrain,‘y’)
plth.set_xlabel(‘Time(seconds)’)
plth.set_ylabel(‘H1 Strain’)
plth.set_title(‘H1 Strain’)
ltime_len = lstrain.shape[0] / rate_l
ltime = np.arange(-ltime_len/2, ltime_len/2, ltime_interval)
pltl = fig.add_subplot(222)
pltl.plot(ltime, lstrain, ‘g’)
pltl.set_xlabel(‘Time(seconds)’)
pltl.set_ylabel(‘L1 Strain’)
pltl.set_title(‘L1 Strain’)
pltref = fig.add_subplot(212)
pltref.plot(reftime, ref_H1)
pltref.set_xlabel(‘Time(seconds)’)
pltref.set_ylabel(‘Template Strain’)
pltref.set_title(‘Template’)
fig.tight_layout()
plt.savefig(“Gravitational_Waves_Original.png”)
plt.show()
plt.close(fig)
- python数据分析与展示-Matplotlib基础
- Python数据分析——Matplotlib
- Python数据分析:数据可视化matplotlib
- python数据分析-matplotlib核心包
- 小白学 Python 数据分析(18):Matplotlib(三)常用图表(上)
- Python数据分析与应用--Matplotlib数据可视化基础之学习笔记
- 使用python中的matplotlib进行绘图分析数据
- python数据挖掘课程 十二.Pandas、Matplotlib结合SQL语句对比图分析
- Python数据分析之可视化一matplotlib(常用方法)
- python3.6中安装numpy,pandas,scipy,scikit_learn,matplotlib等数据分析工具
- 小白学 Python 数据分析(17):Matplotlib(二)基础操作
- Python数据分析三大框架之matplotlib(八)subplot绘制多个子图
- 【python数据挖掘课程】十二.Pandas、Matplotlib结合SQL语句对比图分析
- python数据分析——matplotlib生成折线图,散点图和直方图
- PyThon爬坑记_数据分析matplotlib图例
- Python数据分析matplotlib设置多个子图的间距方法
- 小白学 Python 数据分析(17):Matplotlib(二)基础操作
- python数据分析2——matplotlib应用和应力波的绘制
- 使用python中的matplotlib进行绘图分析数据
- Python数据挖掘04---matplotlib数据可视化分析