Issue
I am trying to plot (y_train, y_test)and then (y_train_pred, y_test_pred) together in one gragh and i use the following code to do so
#plot
plt.plot(y_test)
plt.plot(y_pred)
plt.plot(y_train)
plt.plot(train)
plt.legend(['y_train','y_train_pred', 'y_test', 'y_test_pred'])
Running the above gives me the below graph
But this isn't want i want. I want it in way that it's continous as show below (y_test continues/starts after y_train and y_pred starts after y_train_pred)
Any help will be great.
Solution
You can pass the x
argument:
plt.plot(np.arange(len(y_pred)) + len(y_train),y_test)
plt.plot(np.arange(len(y_pred)) + len(y_train), y_pred)
plt.plot(y_train)
plt.plot(train)
# you seemed to mess up the labels
plt.legend(['y_test', 'y_test_pred', 'y_train','y_train_pred'])
Answered By - Quang Hoang
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.