第二周 数据分析之展示 Matplotlib基础绘图函数实例
生活随笔
收集整理的這篇文章主要介紹了
第二周 数据分析之展示 Matplotlib基础绘图函数实例
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Pyplot基礎圖表函數
Pyplot餅圖的繪制:
Pyplot直方圖的繪制:
Pyplot極坐標圖的繪制:
Pyplot散點圖的繪制:
單元小結:
import numpy as np import matplotlib.pyplot as plt from scipy.io import wavfilerate_h, hstrain= wavfile.read(r"H1_Strain.wav","rb") rate_l, lstrain= wavfile.read(r"L1_Strain.wav","rb") #reftime, ref_H1 = np.genfromtxt('GW150914_4_NR_waveform_template.txt').transpose() reftime, ref_H1 = np.genfromtxt('wf_template.txt').transpose() #使用python123.io下載文件htime_interval = 1/rate_h ltime_interval = 1/rate_l fig = plt.figure(figsize=(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)總結
以上是生活随笔為你收集整理的第二周 数据分析之展示 Matplotlib基础绘图函数实例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 第二周 数据分析之展示 Ma
- 下一篇: 第三周 数据分析之概要 Pan