How to plot a line graph in Matplotlib

You can plot a line graph in Matplotlib with the following code. If you want to learn Python then I will highly recommend you to read This Book.

How to plot a line graph in Matplotlib
How to plot a line graph in Matplotlib

Line Graph 1

from matplotlib import pyplot as plt

x = [1,2,3,4,5]
y = [4,8,12,16,20]

plt.title("Line Graph")
plt.xlabel("X_Axis")
plt.ylabel("Y_Axis")

plt.plot(x,y,color ='green')

plt.show()
Example 1

Line Graph 2

from matplotlib import pyplot as plt

x = [2,4,6,8,10]
y = [7,3,5,1,9]

plt.title("Line Graph")
plt.xlabel("X_Axis")
plt.ylabel("Y_Axis")

plt.plot(x,y,color ='blue')

plt.show()
Example 2

People are also reading:

Best Python Books

What is Computer Vision? Examples, Applications, Techniques

Top 10 Computer Vision Books with Python

Books for Machine Learning (ML)

Free Learning Resources

Leave a Comment

Your email address will not be published.