How to label axis in Matplotlib

You can easily label the axis in Matplotlib with the following code. If you want to learn Python then I will highly recommend you to read This Book.

How to label axis in Matplotlib
How to label axis in Matplotlib

Label the Axis in Matplotlib

The function plt.xlabel is used to add the label on the x-axis and plt.ylabel is used to add the label on the y-axis.

from matplotlib import pyplot as plt

a = [1,2,3,4,5]
b = [6,12,18,24,30]

plt.title("Numbers and Products")

plt.xlabel("Numbers")
plt.ylabel("Products")

plt.plot(a,b)
plt.show()

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.