Matplotlib in Python


Matplot is a very powerful python library to visualize the datasets. It i is built upon the SciPy and the NumPy library.

Further, it would be better to give examples that make you understand the matplot library.

 

Example-1

import matplotlib.pyplot as plt

x=[200,300,400,500,600,700]

y=[200,300,400,500,600,700]

plt.plot(x,y)

plt.show()

Execution on ubuntu

 

The output of the code will be.

 

 

matplotlib

You can observe that there are not any x-axis and y-axis labels. Further, to add these labels you have to use xlabel and ylabel functions. Then the program will be

 

Example-2

import matplotlib.pyplot as plt

x=[200,300,400,500,600,700]

y=[200,300,400,500,600,700]

plt.xlabel(“X Variable”)

plt.ylabel(“Y Variable”)

plt.plot(x,y)

Related Posts  Python Tutorial

plt.show()

 

Command line execution of the program on Ubuntu

Matplotlib

 

 

The output of the program would be

Matplotlib
xylabels

 

Have any Question or Comment?

Leave a Reply

Subscribe to Our Newsletter