python - 分割出图的峰峰值以获得1周期python
问题描述
import matplotlib.pyplot as plt
import numpy as np
import pdb
file = open("Data1r2.txt", 'r')
lines = file.readlines()
file.close()
所以我想要得到的是让代码使用 txt 文件中的数据并绘制图表。我坚持的是我无法弄清楚如何让峰值检测让图表显示峰值,因为我需要计算从一个峰值到另一个峰值的值。
t = []
z = []
y = []
x = []
for line in lines:
parts = line.split(", ")
if len(parts) > 3:
column1 = parts[3].split(':')
column2 = column1[1]
column3 = parts[2].split(':')
column4 = column3[1]
column5 = parts[1].split(':')
column6 = column5[1]
column7 = parts[0].split(':')
column8 = column7[1]
T = column2[0:len(column2)]
Z = column4[0:len(column4)]
Y = column6[0:len(column6)]
X = column8[0:len(column8)]
设置跟踪
T1 = float(T)
t.append(T1)
Z1 = float(Z)
z.append(Z1)
Y1 = float(Y)
y.append(Y1)
X1 = float(X)
x.append(X1)
绘制图表
plt.plot(t,z,label='z')
plt.plot(t,y,label='y')
plt.plot(t,x,label='x')
plt.legend()
plt.show()
我希望能够在 1 个时期内将图表从峰到峰剪掉
解决方案
推荐阅读
- amazon-cognito - 通过 Amplify [Okta] 向 Cognito Federated Identiy 传递代码挑战
- ios - 不接收 Twilio 聊天推送通知(Ionic 和 Firebase)
- android - Studio 构建错误:找不到符号方法 createDeviceProtectedStorageContext()
- php - 用php中的数组更新Mysql Row
- python - 'list' 对象在 Python 中是不可调用的错误
- mongodb - 过滤掉空元素文档
- python - 将列列表和该列的值列表导出到 Excel
- xamarin - 如何选中一个复选框并取消选中另一个复选框
- mysql - MySQL 分区还是像 AWS DynamoDB 这样的 NoSQL?
- java - org.openqa.selenium.NoSuchSessionException:在使用 ChromeDriver Chrome 和 Java 的 Selenium 自动化测试中没有此类会话错误