python - 从带有水平线的 .txt 文件中提取相交值
问题描述
我有一组来自 .txt 文件的数据,我能够成功地在我的 python 脚本上绘制这些数据。现在我想添加两条水平线(y=1.5 和 y=3),当它们与轮廓相交时,它会为我提供该 y 值的所有信息,因此对于每个轮廓,我应该有两行信息(一个对于 y=1.5 和 y=3)。有没有快速的方法呢?
这是我到目前为止的代码:
import glob
import pandas as pd
import matplotlib.pyplot as plt
files = glob.glob('*.txt')
profiles = []
for file in files:
data = pd.read_csv(file, skiprows = [1], sep = '\t', index_col = False, engine='python')
profiles.append(data)
fig, ax = plt.subplots()
for profile in profiles:
z = profile['Z_ZH']
d = profile['DIST_CP']
ax.plot(d, z, label = profile['Data'][0])
ax.legend()
解决方案
推荐阅读
- python - numpy 操作的内存错误:如何绕过这个?
- ruby-on-rails - 错误:列“increment_by”不存在 - Postgres 10 和 Rails 5
- terraform - 创建 CacheSecurityGroup 时出错:InvalidParameterValue
- matlab - 如何在 Matlab 中计算日期时间的“外减法”
- angular - Angular 4 输入指令 onSave
- javascript - 如何在 LiveCycle 中添加一年并从日期中减去一天?
- java - 使用 Java 10 的 jaotc 编译单个类
- python - 我在 pygame.Surface() 里面放了什么?
- c# - Google Assistant Dialogflow API V2 webhook ETag 错误
- sql-server - 基于日期的 T-SQL 每日数据备份