I have this graph
and this code:
plt.style.use('ggplot')
plt.plot(df1['Close'], color='b', label='Historical closing price')
plt.plot(df1_30_pred, color='r', label='30 days prediction')
plt.plot(dftoday['Close'],color='g', label='Real closing price for 30 days')
plt.plot([coefficients[0]*x + coefficients[1] for x in range(len(df1_30_pred))],color='orange', label='30 days prediction trend')
# Adding legend, which helps recognizing the curves according to color
plt.legend(loc='upper left')
plt.xticks(np.arange(0, 300, 10),rotation=45)
plt.yticks(np.arange(0, 200, 10))
plt.legend(loc='upper left')
plt.title('AAPL 30 day prediction', fontsize=20)
plt.xlabel("Date", fontsize=18)
plt.ylabel("Closing price $", fontsize=18)
plt.show()
I want to move the orange trend line to place it on top of the red graph, so it will be between the dates is calculated for.
To do this, specify the indexes 'df1_30_pred'. If, as I indicated, it does not work, then give all the data(dataframe). I'll try to solve the problem.
plt.plot(df1_30_pred.index, [coefficients[0]*x + coefficients[1] for x in range(len(df1_30_pred))],color='orange', label='30 days prediction trend')