Introduction to Matplotlib

Today we are going to explore a very interesting library in python called Matplotlib. Matplotlib is a library for making  plots of arrays in Python. It is used for data visualization and data science.

Let us check it out. First we have to install matplotlib. In Windows, type cmd in the Search . This takes you to the command window. Type “pip install matplotlib” and click Enter. Matplotlib will get installed.

Now let us try some codes using Matplotlib.

Let us first plot some points .


plt.plot plots the points and we are plotting in red colour. ‘ro’ stands for red points. Now if you want to join the 4 points using a straight line then we must replace ‘ro’ by ‘r’.



Let us now plot sine and cosine waves. We use np.linspace to get a range of X values. -np.pi is the start value. -np.pi is the stop value. 256 is the number of samples.




Let us try changing the color and line width.



Hope you found matplotlib interesting. Please go to the Official documentation and try out various commands and enjoy plotting data !

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Powered by

Up ↑

%d bloggers like this: