Answers for "python plot 2 graphs in one"

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
2

multiple plot in one figure python

import matplotlib.pyplot as plt

plt.plot(<X AXIS VALUES HERE>, <Y AXIS VALUES HERE>, 'line type', label='label here')
plt.plot(<X AXIS VALUES HERE>, <Y AXIS VALUES HERE>, 'line type', label='label here')
plt.legend(loc='best')
plt.show()
Posted by: Guest on May-07-2020

Code answers related to "python plot 2 graphs in one"

Python Answers by Framework

Browse Popular Code Answers by Language