问题描述
在代码中,我找出了两条线的交点(22,50),并希望在图形中显示(有一个箭头指向与(22,50)的交点),并想知道是否社区可以帮助我。
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from shapely.geometry import Linestring
df = pd.read_csv("C:/Users/rajaa/Desktop/tril.csv")
t = df['time']
mu = df['material uts']
ps = df['pipe stress']
plt.figure(figsize = (8,5),dpi = 100)
fig,ax = plt.subplots()
plt.plot(t,mu,'r',label='Material UTS')
plt.plot(t,ps,'b--',label=[enter image description here][1]'Pipe Stress as the pipe is depressurized')
plt.title('Graph 1',fontdict={'fontname': 'Arial','fontsize': 20})
plt.xticks(np.arange(0,32,2))
plt.yticks(np.arange(0,120,10))
plt.xlabel('Time (minutes)')
plt.ylabel('Pipe stress and UTS (MPa)')
plt.legend()
first_line = Linestring(np.column_stack((t,mu)))
second_line = Linestring(np.column_stack((t,ps)))
intersection = first_line.intersection(second_line)
plt.plot(*intersection.xy,'ro')
x,y = intersection.xy
plt.show()
解决方法
ax.arrow(0,22,50,head_width=0.05,head_length=0.1,fc='k',ec='k')