Matplotlib is a data visualization library in Python used for plotting static, animated, and interactive visualizations with a high level of flexibility.
In Python, there are multiple kinds of Matplotlib plots available and in this course, we will go over everything from an introduction to Matplotlib to creating 3D Matplotlib plots.
Installing Matplotlib in Python using pip
Matplotlib can be installed using the Python Package Manager, pip, as follows:
$ pip install matplotlib
Note: If you are using Anaconda, Matplotlib comes pre-installed.
Importing Matplotlib in Python
Starting from this section onwards, we will be using Jupyter Notebooks as our Python IDE.
To import Matplotlib in Python, write the following code and run it:
# Libraries/Modules import conventions import matplotlib as mpl import matplotlib.pyplot as plt # For interactive matplotlib sessions, turn on the matplotlib inline mode %matplotlib inline
Check Matplotlib version in Python
To check the version of the installed Matplotlib library, write the following code and run it:
# Check version of matplotlib installed print(mpl.__version__) #Printed version: 3.1.1
The output of the code will be displayed as following in Jupyter Notebook:
If your Matplotlib version is greater than 3.0.0, then everything is now ready!
This is it for the basic introduction to Matplotlib. Now you are ready to start plotting your own Matplotlib plots in Python.
Head over to the next chapter on ‘Basics of Matplotlib‘.
Do you want to learn Python, Data Science, and Machine Learning while getting certified? Here are some best selling Datacamp courses that we recommend you enroll in:
- Introduction to Python (Free Course) - 1,000,000+ students already enrolled!
- Introduction to Data Science in Python- 400,000+ students already enrolled!
- Introduction to TensorFlow for Deep Learning with Python - 90,000+ students already enrolled!
- Data Science and Machine Learning Bootcamp with R - 70,000+ students already enrolled!