Answers for "matplotlib plot 2 graphs"

3

show multiple plots python

#One way to plot two figure at once
f = plt.figure(1)
plt.plot([1,2],[2,3])
f.show()

g = plt.figure(2)
plt.plot([2,7,3],[5,1,9])
g.show()
Posted by: Guest on April-24-2020
1

how to plot 2 graphs in same plot in matplotlib

x1 = [1, 2, 3]
Data for the first line

y1 = [4, 5, 6]

x2 = [1, 3, 5]
Data for the second line

y2 = [6, 5, 4]

plt.plot(x1, y1)
plt.plot(x2, y2)

plt.legend(["Dataset 1", "Dataset 2"])
Create a legend for the graph
Posted by: Guest on June-21-2021

Code answers related to "matplotlib plot 2 graphs"

Python Answers by Framework

Browse Popular Code Answers by Language