## What is Matplotlib?

Matplotlib is an open-source Python library for 2D plotting. You can use it across Python environments ranging from simple Python scripts to interactive Jupyter notebooks.

## Why is Matplotlib so popular?

Using Matplotlib has become easier with the availability of simple API calls for plotting all sorts of graphs.There are one line function calls for everything from line graphs to box plots. (*Just a line of code! Sounds groovy, right *😉?)

Matplotlib also has a large community that helps Matplotlib users with various types of technical queries and questions.

Lastly, upcoming plotting libraries that have more aesthetic appeal than the veteran Matplotlib are also built on top of Matplotlib. Seaborn is one such example. Even the internal plotting commands in Pandas use Matplotlib under the hood.

## Who uses Matplotlib?

Using graphs to convey the final results of a data science project is a standard practice. Visualizations help simplify complex technical details, which business teams can interpret easily.

Data analysts use Matplotlib to visually examine trends and statistics in large datasets and draw relevant insights.

Machine learning engineers use Matplotlib to monitor their model’s performance via metrics such as training loss and testing loss by plotting their reduction over time.

## How can you get started with Matplotlib?

### Installing Matplotlib

If you use pip, then type the following command to install Matplotlib as part of your Python environment:

`python -m pip install -U matplotlib`

If you use Anaconda, then you don’t have to install anything since it comes pre-installed with the latest version of Matplotlib.

Once installed, import Matplotlib in your Python shell with the following command:

`import matplotlib.pyplot as plt`

After the import, you can start plotting.

### Plotting a line graph

Run the following command to plot a simple line graph:

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

where:

- plt.plot() - plot function in Matplotlib
- [1,2,3] - a list of values for the X-axis
- [4,5,6] - a list of corresponding values for the Y-axis

To learn more about the various functions that Matplotlib offers, you can go through the official Matplotlib User Guide.

Think we're missing something? 🧐 Help us update this article by sending us your suggestions here. 🙏