如何使用Matplotlib在图形中显示交点

时间:2019-06-19 13:37:07

标签: python matplotlib

我试图在图形上显示相交点,但问题是当我简单地绘制它们以得到结果时,数据的形状是不同的

这是我的图形代码

plt.plot(x,color='green')
plt.plot(y, color='blue')
plt.plot(z, color='orange')
plt.legend()
plt.show()

Results of graph

但是当我试图找到相交点时,我得到了错误

unsupported operand type(s) for -: 'list' and 'list'

在此行

idx = np.argwhere(np.diff(np.sign(y - x))).flatten()

这是我的代码,查找不起作用的交点

import numpy as np
import matplotlib.pyplot as plt

x=test1.history['acc']
y=test2,.history['acc']
z=test3.history['acc']

plt.plot(x, y, '-')
plt.plot(x, z, '-')

idx = np.argwhere(np.diff(np.sign(y - x))).flatten()
plt.plot(x[idx], y[idx],z[idx], 'ro')
plt.show()

我正在获取结果,但它显示这样的结果是无效的

enter image description here

0 个答案:

没有答案