How to import Matplotlib in Python?

Posted 2 months ago
import matplotlib as mpl

# Importing particular feature from Matplotlib
import matplotlib.pyplot as plt

Matplotlib is a popular and the most useful comprehensive Python library for creating static, animated, and interactive visualizations in Python. In order to avail of the features of third-party libraries or modules, you have to import them in the current Python script. You can use just a normal Python import statement to integrate that library inside your working project.

import matplotlib as mpl

# Importing particular feature from Matplotlib
import matplotlib.pyplot as plt

In Python, the "as" keyword is used to create an alias. It is an extremely useful approach in the case of large scripts where a lot of modules are being imported to create a feature-rich application. The name alias solves the problem of imported library component name clashes.