Jul-18-2017, 12:06 AM
Dear Python Users,
I tried to plot a graph from two lists on the same graph. However, what I get is that two lists are plotted against each other. How can I plot two lists on the same graph, but with different colors?
I tried to plot a graph from two lists on the same graph. However, what I get is that two lists are plotted against each other. How can I plot two lists on the same graph, but with different colors?
import matplotlib.pyplot as plt
train_W = [1,2,3,4,5,6]
train_X = [1,2,3,4,5]
train_Y = [10, 20, 30, 40, 50]
train_Z = [10, 20, 30, 40, 50,25]
alpha = float(input("Input alpha: "))
forecast = []
for x in range(0, len(train_X)+1):
if x==0:
forecast.append(train_Y[0])
else:
forecast.append(alpha*train_Y[x-1] + (1 - alpha) * forecast[x-1])
plt.plot(forecast,train_Z,'g')
plt.show()
