我正在使用matplotliband numpy,我正在制作图表。我使用的数据格式是.csv. 在csv我使用的文件中有三列。我想知道,有没有办法只导入数据,直到我的一个列的峰值/最小值?
背景:我正在使用具有脂质单层的 Langmuir 槽并压缩和扩展屏障以增加/减少我试图针对该区域绘制压力和荧光的区域。但是,获取这些数据的程序会执行一个完整的压缩和扩展循环,当波谷处于其最小区域时,我不能简单地停止数据收集。所以我想让 Python 只导入,直到面积值达到最低点。
example of how my data looks
Area | Presure | Intensity
12500 |3 | 1
11500 |6 | 12
etc |8 |25
3000 |12 |38
3500 |19 |54 <==want it to stop importing here
4500 |16 |47
这可能吗??
我已经添加了 Phi 的内容,但它似乎不起作用?我仍然得到包含在我的图形代码中的所有值,如下所示 import matplotlib.pyplot as plt import numpy as np import pandas as pd
df = pd.read_csv("C:\\Users\\Owner\\Desktop\\Thunberg,Dametre\\5-29 Data and
movies\\New folder (2)\\Data 2.csv", sep=',')
rowmin = df.area.idxmax()
df[:(1 + rowmin)]
fig, ax1 = plt.subplots()
area, pressure, pixel = np.loadtxt
("C:\\Users\\Owner\\Desktop\\Thunberg,Dametre\\5-29 Data and movies\\New
folder
(2)\\Data 2.csv", delimiter=",", skiprows=1, unpack=True)
plt.plot(area,pressure, label='area/pressure!',color='b')
plt.xlabel('area', color='b')
plt.ylabel('Pressure', color='b')
ax1.tick_params('y', colors='b')
ax2 = ax1.twinx()
this ax2 creates a second x axis
ax2.set_ylabel('Intensity (measured by average pixel value)', color='r')
this labels the secondary axis and chooses its color
ax2.tick_params('y', colors='r')
this Chooses the color of the ticks in the axis
ax2.plot(area,pixel, color='r')
this is what actually plots the second graph of area vs intensity
plt.title('Kibron Trough Pressure-Area-Intensity Graph')
plt.legend()
plt.show()