当我只有一个已知的Y坐标方程,即P = a * b(其中a& b定义的值为0.8,150)和x坐标完全未知时,如何在曲线绘图上得到一个点没有连接x和y的方程(例如:y = mx b; #i没有这种方程).因此,现在目标是,如果我将’Y坐标’值设置为120并且需要通过从未知’x-coordiante’值获取距离或路径来绘制曲线上的点.
我尝试了如下代码
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import InterpolatedUnivariateSpline
# given values
y = np.array([0, 38.39, 71.41, 99.66, 123.67, 143.88, 160.61, 174.03, 184.16, 190.8, 193.52])
x = np.array([0, 0.37, 0.74, 1.11, 1.48, 1.85, 2.22, 2.59, 2.96, 3.33, 3.7])
x_val = np.linspace(0,7) #limts on x-axis
a = 0.8
b = 150
y_val = np.multiply(a, b)
yinterp = np.interp(x_val, x, y)
plt.plot(x, y, '-')
plt.plot(x_val, yinterp, 'o')
#here i need to plot a exact point w.r.t to y_val
#and also need to show the distance with a line from the selected x