Python Forum
How to plot two list on the same graph with different colors?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to plot two list on the same graph with different colors?
#1
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?


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()
Reply


Messages In This Thread
How to plot two list on the same graph with different colors? - by Alberto - Jul-18-2017, 12:06 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Count image's colors very fast flash77 18 1,614 Mar-05-2024, 06:12 PM
Last Post: deanhystad
  can openpyxl read font colors mperemsky 3 1,768 May-09-2023, 11:18 AM
Last Post: MindKeeper
  first time use plot - I get empty graph korenron 6 2,143 Feb-04-2023, 02:14 PM
Last Post: deanhystad
  ANSI not working for change of text colors BliepMonster 10 3,436 Nov-10-2022, 09:28 AM
Last Post: BliepMonster
  How to do bar graph with positive and negative values different colors? Mark17 1 5,187 Jun-10-2022, 07:38 PM
Last Post: Mark17
  Unable to plot the graph as needed drunkenneo 1 6,403 May-26-2021, 11:04 AM
Last Post: cygnus_X1
  How to plot 3D graph of non numerical value? Gevni 0 2,235 Mar-05-2021, 02:50 PM
Last Post: Gevni
  Python Matplotlib: How do I plot lines with different end point in the same graph? JaneTan 0 1,594 Feb-28-2021, 11:56 AM
Last Post: JaneTan
  Plot Graph quest_ 2 2,140 Jan-18-2021, 07:58 PM
Last Post: quest_
  How to plot intraday data of several days in one plot mistermister 3 2,935 Dec-15-2020, 07:43 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020