如何在时间轴X轴上移动绘制线?
我有此图
和此代码:
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 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 quot;, 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为此,请指定索引“ DF1_30_PRED”。
如我指出的那样,它不起作用,请提供所有数据(数据框架)。我将尝试解决问题。
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.