HOME/Articles/

matplotlib example multiple lines plotting (snippet)

Article Outline

Python matplotlib example 'multiple lines plotting'

Modules used in program:

  • import numpy as np
  • import matplotlib.pyplot as plt

python multiple lines plotting

Python matplotlib example: multiple lines plotting

# multiple lines plotting on the same graph

import matplotlib.pyplot as plt
import numpy as np

x = np.arange(1,10)  # values from 1 to 10
y1=x+2
y2=x*6
y3=x/5
plt.plot(x,y1,x,y2,x,y3)
plt.show()