Matplotlib is a package in Python that is used in Data Science to create informative charts and graphs to represent data visually. Matplotlib is one of the most popular packages in Python.
If you want to learn Matplolib, you should check our free reading tutorials: Matplotlib Tutorial
There are many different ways to install Matplotlib. In this article, I will cover two different ways to install Matplotlib. The first one using pip
installer, and the second one uses Anaconda.
So let's jump right in.
Get Done with it!
If you just need the command to install the Matplotlib package with no additional information, just run the command below:
python -m pip install -U pip
python -m pip install -U matplotlib
I hope that works fine for you. If you want to understand what you just did. Just follow along till the end of this article.
Install Pip and Matplotlib
You must have Python 3.x installed on your system to install Matplotlib. If you do not have Python installed, do not worry, this tutorial will guide you on how to install Python on your local system.
Python installation brings along pip with it. If you have Python installed already then you can upgrade the version of pip, by running the following command:
pip install pip –upgrade
Now we are ready to install Matplotlib.
Install Matplotlib
Matplotlib package is officially distributed in the form of a Matplotlib Wheel file. You can install Matplotlib on macOS, Windows, or Linux system using the pip command.
Just run the following command:
python -m pip install -U matplotlib
You can find all the details about the Matplotlib package here: https://pypi.org/project/matplotlib/
This will install the Matplotlib package on your system. If you face any trouble installing the Matplotlib package this way, then you can try using Anaconda.
Install Matplotlib on Anaconda
If you are familiar with or already using Anaconda, then follow the below steps to install the Matplotlib package. (Even if you do not know about Anaconda, try downloading it and setting it up, follow this link for that.)
The Matplotlib package is available as conda package. If you want to list and see all the conda packages installed on your system, you can run the following command:
conda list
If you do not see Matplotlib listed, that means the default Anaconda installation didn't bring the Matplotlib module along. (some versions do include the Matplotlib module by default). Run the following command to install it:
conda install matplotlib
And you are done.