how to plot the line to trajectory
x=[]
x = np.arange(0,15000)
for i in range(0,2):
plt.figure(figsize=(15,6))
plt.plot(x,FC_COP[0:15000,i],color='red')
plt.plot(x,Pred_COP[0:15000,i],markerfacecolor='none',color='green')
plt.title('COP Calculation (Training Data)')
plt.ylabel(col_COP[i])
plt.xlabel('Time(s)')
plt.show()
I want to make it to trajectory like below:
I've try use below code to make the data to trajectory as above plot, but its not working.
x = range(15000)
y1 = FC_COP[:,0]
y2 = FC_COP[:,1]
pyplot.plot(x,y1)
pyplot.plot(x,y2)
pyplot.show()
the result is not what I want
CodePudding user response:
What your plot suggests is that you want to plot FC_COP[:,0]
vs FC_COP[:,1]
So, instead of using any time variable x, directly plot them against each other:
pyplot.plot(FC_COP[:,0],FC_COP[:,1])
pyplot.show()
As your dataset periodically returns to zero, this plot will look a bit ugly. To avoid that, you could filter out zero values first:
y1 = FC_COP[:,0]
y2 = FC_COP[:,1]
data_filter = abs(y1) > 0
pyplot.plot(y1[data_filter], y2[data_filter])
pyplot.show()
To show the trajectories of real and predicted values, add two plots:
real_x = FC_COP[:,0]
real_y = FC_COP[:,1]
predict_x = Pred_COP[:,0]
predict_y = Pred_COP[:,1]
data_filter = abs(real_x) > 0
pyplot.plot(real_x[data_filter], real_y[data_filter])
pyplot.plot(predict_x[data_filter], predict_y[data_filter])
pyplot.show()