Plotting Multiple Line Chart and and legend - Pyplot of Mathplotlib

Plotting Multiple Line Chart and and legend - Pyplot of Mathplotlib

Instructor-svgAl-Mamun Sarkar
Apr 02 , 2020

Plotting Multiple Line Chart - Pyplot of Mathplotlib Module. The following code shows how to plot multiple line chart using pyplot of matplotlib module.

 

Import module:

import matplotlib.pyplot as plt

Create Data:

x = [10, 25, 30]
y = [30, 60, 40]

x2 = [10, 15, 30]
y2 = [20, 35, 25]

 

Adding Multiple Graph together:

 

plt.plot(x, y, label='This is First line')
plt.plot(x2, y2, label='This is Second Line')
plt.title("Welcome to the Ploting \n This is Another Line")
plt.xlabel('Label for X-Axis')
plt.ylabel('Label of Y-Axis')
plt.legend()
plt.show()

  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram