绘制两个不同系列中两个点之间的距离

2024-10-04 03:22:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我刚刚画了两个系列,我想,对于x轴上的每个值,用一条线连接它们,并写下它们的距离(我已经计算过)。我已经在为画一条线而挣扎:没有

plt.plot([result[0][:no_obs], result[1][:no_obs]], 'ro-')

在代码中,结果作为第一张图片。然而,有了它,结果就成了第二幅图

df = pd.read_csv(csv, header=None)
no_obs = len(df[0]);
rho1 = 0.2
rho2 = 0.4

plt.plot(result[0][:no_obs], 'go')
plt.plot(result[1][:no_obs], 'b*')
plt.plot([result[0][:no_obs], result[1][:no_obs]], 'ro-')

plt.title("rho1=%s - rho2=%s" % (str(rho1), str(rho2)))
plt.show()

enter image description here

enter image description here

更新

这是我的数据集(y值)

enter image description here


Tags: csvno代码距离dfroplot图片