Tutorial Playlist

Python Tutorial for Beginners


The Best Tips for Learning Python

Lesson - 1

How to Install Python on Windows?

Lesson - 2

Top 10 Python IDEs in 2022: Choosing The Best One

Lesson - 3

A Beginner’s Guide To Python Variables

Lesson - 4

Understanding Python If-Else Statement

Lesson - 5

Python Numbers: Integers, Floats, Complex Numbers

Lesson - 6

Python Strings | Simplilearn Python Tutorial

Lesson - 7

The Basics of Python Loops

Lesson - 8

Python For Loops Explained With Examples

Lesson - 9

Introduction to Python While Loop

Lesson - 10

Everything You Need to Know About Python Arrays

Lesson - 11

All You Need To Know About Python List

Lesson - 12

How to Easily Implement Python Sets and Dictionaries

Lesson - 13

A Handy Guide to Python Tuples

Lesson - 14

Everything You Need to Know About Python Slicing

Lesson - 15

Python Regular Expression (RegEX)

Lesson - 16

Learn A to Z About Python Functions

Lesson - 17

Objects and Classes in Python: Create, Modify and Delete

Lesson - 18

Python OOPs Concept: Here's What You Need to Know

Lesson - 19

An Introduction to Python Threading

Lesson - 20

Getting Started With Jupyter Network

Lesson - 21

PyCharm Tutorial: Getting Started with PyCharm

Lesson - 22

The Best NumPy Tutorial for Beginners

Lesson - 23

The Best Python Pandas Tutorial

Lesson - 24

An Introduction to Matplotlib for Beginners

Lesson - 25

The Best Guide to Time Series Analysis In Python

Lesson - 26

An Introduction to Scikit-Learn: Machine Learning in Python

Lesson - 27

A Beginner's Guide To Web Scraping With Python

Lesson - 28

Python Django Tutorial: The Best Guide on Django Framework

Lesson - 29

Top 10 Reason Why You Should Learn Python

Lesson - 30

10 Cool Python Project Ideas For Beginners in 2021

Lesson - 31

The Best Ideas for Python Automation Projects

Lesson - 32

12 Tips On How To Become a Python Developer

Lesson - 33

The Best Guide for RPA Using Python

Lesson - 34

Comprehending Web Development With PHP vs. Python

Lesson - 35

The Best Tips for Learning Python - REMOVE

Lesson - 36

The Best Way to Learn About Box and Whisker Plot

Lesson - 37

An Interesting Guide to Visualizing Data Using Python Seaborn

Lesson - 38

The Complete Guide to Data Visualization in Python

Lesson - 39

Everything You Need to Know About Game Designing With Pygame in Python

Lesson - 40

The Complete Simplified Guide to Python Bokeh

Lesson - 41

Top 150 Python Interview Questions and Answers for 2022

Lesson - 42
An Introduction to Matplotlib for Beginners

To make necessary statistical inferences, it becomes essential to visualize your data, and Matplotlib is one such solution for Python users. It is a comprehensive plotting library useful for those working with Python and NumPy.

What is Matplotlib?

  • Matplotlib is an open-source drawing library that supports various drawing types
  • You can generate plots, histograms, bar charts, and other types of charts with just a few lines of code
  • It’s often used in web application servers, shells, and Python scripts

Python Training Course

Learn Data Operations in PythonExplore Course
Python Training Course

Getting Started With Pyplot

Pyplot is a Matplotlib module that provides simple functions for adding plot elements, such as lines, images, text, etc. to the axes in the current figure.

Let's begin our tutorial with a simple graph that uses fundamental Matplotlib code in Jupyter Notebook. 


 Fig: Basic plot-matplotlib tutorial

Note that the first array appears on the x-axis, and the second array appears on the y-axis of the plot.

Let us now see how we can add a title, as well as the x-axis and y-axis names, using the title(), xlabel(), and ylabel() methods, respectively.


Fig: label()

Users can also specify the size of the figure using the figure() method. Additionally, users can pass values as tuples, which make up the length of rows and columns to the argument figsize.


Fig: figure() method-matplotlib tutorial

Matplotlib Subplots

You can use the subplot() method to add more than one plot in a figure. 

Syntax: plt.subplots(nrows, ncols, index)

The three-integer arguments specify the number of rows and columns and the index of the subplot grid.



Fig: subplot()

The add_subplot() function of the figure class enables us to add a graph inside a graph.


Fig: add_subplot()

Free Course: Programming with Python

Learn the Basics of Programming with PythonEnroll Now
Free Course: Programming with Python

Important Types of Plots

  • Bar graphs
  • Histograms
  • Scatter plots

1. Bar Graphs

A  bar graph presents data with heights and lengths proportional to the values they present.

Syntax: ax.bar(x, height, width, bottom, align)



Fig: Bar graph-matplotlib tutorial

The axes label is a region of the image with data space. 

An axes object is added to figure by the add_axes() method. The syntax for the axes object is: ax = fig.add_axes([left,right,width,height]).

2. Histograms

A histogram is used to understand the distribution of a continuous numerical variable.



Fig: Histogram

3. Scatter Plots

Scatter plots are used to represent values for two different numeric variables.


Fig: Scatter plot



Fig: Scatter plot

Matplotlib Three-Dimensional Plotting

Importing the mplot3d toolkit enables users to create three-dimensional plots. 



Fig: Three-dimensional plotting-matplotlib tutorial

Practice Example

For this practice drill, you’ll write a Python program that will create a pie chart showing the popularity of programming languages.



Fig: Solution

Autopct is used to display values on the pie slice.

Looking forward to make a move to programming? Take up the Python Training Course and begin your career as a professional Python programmer.


In this Matplotlib tutorial article, we discussed the basic concepts related to the Matplot library. We looked at how to create basic graphs and plots, and its different functions. We discussed three-dimensional plotting and sub-plots as well. 

If you have any other questions, please feel free to ask them in our comments section, and we'll get back to you as soon as possible.

Want to Learn More About Python?

Python is one of the most widely used programming languages in the fields of data science and analytics. That means there’s a high demand for qualified professionals. If you’re ready to boost your career in these exciting fields, check out our Python Training Course today!

About the Author

Aryan GuptaAryan Gupta

Aryan is a tech enthusiast who likes to stay updated about trending technologies of today. He is passionate about all things technology, a keen researcher, and writes to inspire. Aside from technology, he is an active football player and a keen enthusiast of the game.

View More
  • Disclaimer
  • PMP, PMI, PMBOK, CAPM, PgMP, PfMP, ACP, PBA, RMP, SP, and OPM3 are registered marks of the Project Management Institute, Inc.