Need to **visualize data in Jupyter Notebook**? **Matplotlib** is the go-to Python library for creating **charts, graphs, and plots**. In this tutorial, we’ll show you how to **install Matplotlib using pip** inside Jupyter Notebook and create your first plot!
By the end of this guide, you'll be able to **install, verify, and use Matplotlib** for data visualization in Jupyter Notebook with ease.
---
### **What You’ll Learn in This Video:**
How to install **Matplotlib** in Jupyter Notebook
Using **pip** to install Matplotlib inside a notebook
Verifying the installation and checking Matplotlib version
Creating a simple **line plot** using Matplotlib
Fixing common Matplotlib installation errors
---
### ** Step-by-Step Guide to Installing Matplotlib in Jupyter Notebook**
#### **1⃣ Open Jupyter Notebook**
Launch Jupyter Notebook by running the following command in your terminal or command prompt:
```bash
jupyter notebook
```
#### **2⃣ Install Matplotlib Using PIP in Jupyter Notebook**
In a Jupyter Notebook cell, install Matplotlib using pip by running:
```python
!pip install matplotlib
```
#### **3⃣ Verify Installation**
After installation, verify that Matplotlib is installed correctly by running:
```python
import matplotlib
print(matplotlib.__version__) # This will print the installed Matplotlib version
```
#### **4⃣ Create a Simple Plot in Jupyter Notebook**
Now, let's create a simple **line plot** to test Matplotlib:
```python
import matplotlib.pyplot as plt
# Sample Data
x = [1, 2, 3, 4, 5]
y = [10, 20, 25, 30, 40]
# Create a Line Plot
plt.plot(x, y, marker='o', linestyle='-', color='b', label="Line Chart")
plt.xlabel("X Axis")
plt.ylabel("Y Axis")
plt.title("Simple Line Plot in Matplotlib")
plt.legend()
plt.show()
```
---
### **Fixing Common Errors**
- **Error: "matplotlib not found"**
Ensure you installed Matplotlib in the correct Python environment:
```python
!pip install --user matplotlib
```
- **Plots Not Displaying in Jupyter Notebook?**
Add this magic command at the beginning of your notebook cell:
```python
%matplotlib inline
```
---
### ** Useful Links:**
Matplotlib Documentation: [https://matplotlib.org/stable/contents.html](https://matplotlib.org/stable/contents.html)
Jupyter Notebook Guide: [https://jupyter.org/](https://jupyter.org/)
**Have Questions?** Drop a comment below! If this tutorial helped you, **LIKE** this video, **SUBSCRIBE** for more Python and Jupyter Notebook tutorials, and **SHARE** with your friends!
**Hashtags:**
#Matplotlib #JupyterNotebook #DataVisualization #Python #PythonPlots #MachineLearning #DataScience #Graphing #JupyterTips