繁体   English   中英

Plot 和从数据帧绘制的两条曲线之间的交点的返回点

[英]Plot and return points of Intersection between two curves plotted from dataframes

我对编码有点陌生,目前正在尝试找出如何找出从数据帧绘制的两条曲线的交点。

曲线是:

这里

这是我现在拥有的代码。

GZ_positive = data.loc[data["GZ"] >= 0] 

x_new = GZ_positive['heel']
y_new = GZ_positive['GZ']


wind_heeling = pd.read_csv('wind_heeling.csv')  

GZ_positive['GZ'] = GZ_positive['GZ']/13400
wind_heeling['GZ_wind'] = wind_heeling['GZ_wind']/13400

x_wind = wind_heeling['Heel']
y_wind = wind_heeling['GZ_wind']

plt.figure()
plt.plot(x_new,y_new)
plt.plot(x_wind,y_wind)
plt.grid(True)
plt.show()

然后我想在交叉点之前和之后删除橙色线的所有点。 此分析的目的是计算橙色图下方但与蓝色图相交的点之间的面积:

这里 .

在网上发现了一些类似的问题,但似乎没有任何效果(或者我做错了)。 如果有人能指出我正确的方向,将不胜感激。 谢谢!

您可以定义两条新曲线。 一条将由两条曲线的逐点最小值给出,另一条将是一条为零的水平线。 现在,您可以使用matplotlib中的fill_between方法。 这是一个例子:

xs = np.linspace(0, 10, 100)
ys = -xs**2 - 4 + 10*xs

df = pd.DataFrame({
    "one": 5,
    "two": ys,
})

ax = df.plot()
ax.set_ylim(0, 30)

upper = df.min(1)
lower = np.zeros(df.shape[0])

ax.fill_between(df.index, lower, upper)

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM