我试图用Plotly找到并注释两条直线的交点。我知道我们可以使用(plt.plot(*intersection.xy,'ko'))
在Mathplotlib中获得交点,但是如何在plotly中获得交点,或者是否可以获得交点
import numpy as np
import pandas as pd
import plotly.express as px
test = pd.merge(ps,uts,on = 'Time')
print(test)
time = test['Time']
omfr = test['Orifice Mass Flow Rate']
qab = test['Qab']
fig = px.line(test, x=time, y=[omfr,qab])
fig.update_layout( title='Pipe stress and UTS (MPa)',xaxis_title="Time (s)",yaxis_title="Pipe stress and UTS (MPa)",
hovermode='x')
注释和显示交点很容易发现这是困难的部分,我在这方面的建议直接基于postHow do I compute the intersection point of two lines中的贡献。当我有时间的时候,我会在我的建议中加入几行关于细节的内容。现在,我的答案末尾的完整代码片段将使用此数据集生成下图:
数据
绘图
编辑-注释
如果要更改文本批注,只需更改
。。。例如:
结果:
完整代码
相关问题 更多 >
编程相关推荐