嗨我正在尝试绘制一个基本的插值图,用data2插入data1,用SecondData2插入SecondData1 ..但我不知道我可以把我的第一个数据集和第二个数据集放在哪里。我几乎在天..
import numpy as np
import matplotlib.pyplot as plt
# first data set
data1 = [15000, 11000, 8000, 4000, +1000, +552, -708, -8000, -8, 10000, +15000]
data2 = [30E-06, 13E-06, 2E-06, -179E-06, -7E-06, -19E-06, -30E-06, -10E-06, -1.9E-06, 30E-06, 30E-06]
X1 = np.linspace(-15000,15000,11)
Y1 = np.sin(X1)
# second data set
SecondData1 = [10000, 4000, 447, -4000, -6000, -9000, -4000,-122, 4000, +9000, +10000]
SecondData2 = [27E-06, 28E-06, 28E-06, 27E-06, 28E-06, 30E-06, -28E-06, -27E-06, 27E-06, 29E-06, 27E-06]
X2 = np.linspace(-10000, 10000, 11)
Y2 = np.cos(X2)
# get interpolated values of Y1 evaluated at X2
Y1_interp = np.interp(X2, X1, Y1)
# plot interpolated Y1 vs Y2
plt.plot(Y1_interp, Y2)
plt.show()