简体   繁体   English

如何以不同的颜色绘制一条线以继续另一个情节? Matplotlib

[英]How to plot a line in a different colour to continue another plot? Matplotlib

I have a question about plotting data in Matplotlib.我有一个关于在 Matplotlib 中绘制数据的问题。 How can I plot a line in a different colour to continue another line in Matplotlib (as shown below) to show a split in Training/Testing data or Current Price/Predicted Price?如何以不同颜色绘制一条线以继续 Matplotlib 中的另一条线(如下所示)以显示训练/测试数据或当前价格/预测价格的拆分?

在此处输入图片说明

I am using Python3 in Jupyter Notebook if it helps.如果有帮助,我将在 Jupyter Notebook 中使用 Python3。 Thanks!谢谢!

You can split the training data and testing data into two and plot them in different colour in the same figure.您可以将训练数据和测试数据一分为二,并在同一图中以不同颜色绘制它们。

plt.plot(train_x, train_y, 'blue', test_x, test_y, 'orange')
plt.legend(["Train","Test"])
plt.show() 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM