Introduction and Installation

Matplotlib is the most widely used Python module to plot graphs. It could produce publication-ready figures easily and be used in different platforms.

pyplot module of Matplotlib has a MATLAB-like interface, therefore it is easier to use pyplot if you are already user of MATLAB.

Install Matplotlib


- pip

pip install matplotlib

This pip command also installs the Matplotlib dependencies automatically.

- Install Wheel File

You could also download the unofficial pre-built 32 or 64-bit Windows Matplotlib wheel file of Python 2.7 or Python 3.4+ version from the famous site of Unofficial Windows Binaries for Python Extension Packages.

After the wheel file is downloaded, use the command below to install the wheel file.

pip install matplot_wheel_file_path

Refer to the wheel file installation guide here.


Open the Linux terminal and use the command below according to the Python version in your system.

Python 2.7

sudo apt-get install python-matplotlib

Python 3.4+

sudo apt-get instlal python3-matplotlib

Matplotlib Hello World

Now we will take the first bite of Matplotlib.

from matplotlib import pyplot as plt

plt.plot([1,2,3], [4,5,6])

This example plots the graph of a straigt line that has the 2-D data - [1,2,3],[4,5,6].

from matplotlib import pyplot as plt

As we mentioned above, pyplot is a MATLAB-like plotting module.

plt.plot([1,2,3], [4,5,6])

It plots the x and y using default line and color style because no extra argument is passed here.

It displays the figure. The plotting figure will not be shown before this line is executed.

Matplotlib Hello World