Answers for "plot 2 line graphs py"

0

python plot two lines on same graph

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()
Posted by: Guest on February-24-2021
0

matplotlib draw a line between two points

import matplotlib.pyplot as plt
# Just plot a normal line plot consisting of the two desired points
p1 = [0,3]
p2 = [1,-2]
x, y = [p1[0], p2[0]], [p1[1], p2[1]]

plt.plot(x,y)
plt.show()
Posted by: Guest on September-06-2021

Python Answers by Framework

Browse Popular Code Answers by Language