Question : python plot two lines on same graph
Answered by : panos-karamolegkos
import matplotlib.pylot as plt
x_coordinates = [1, 2, 3]
y1_coordinates = [1, 2, 3]
y2_coordinates = [3, 4, 5]
fig = plt.figure(1)
plt.plot(x_coordinates, y1_coordinates) # plot first line
plt.plot(x_coordinates, y2_coordinates) # plot second line
plt.show()
Source : | Last Update : Wed, 03 Mar 21
Question : python plot multiple lines in same figure
Answered by : charlesalexandre-roy
# Short answer:
Call plt.plot() as many times as needed to add additional lines to plot.
# Example usage:
import matplotlib.pylot as plt
x_coordinates = [1, 2, 3]
y1_coordinates = [1, 2, 3]
y2_coordinates = [3, 4, 5]
plt.plot(x_coordinates, y1_coordinates) # plot first line
plt.plot(x_coordinates, y2_coordinates) # plot second line
Source : https://www.kite.com/python/answers/how-to-plot-multiple-lines-on-the-same-graph-in-matplotlib-in-python#:~:text=Use%20plt.,lines%20on%20the%20same%20graph&text=plot(x%2C%20y)%20multiple,of%20x%20and%20y%20coordinates. | Last Update : Wed, 16 Sep 20