# Python Matplotlib Module

Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. `matplotlib.pyplot` is a collection of functions that make matplotlib work like MATLAB.

## Installation

```bash
pip install matplotlib
```

## Importing the Module

```python
import matplotlib.pyplot as plt
```

## Basic Plotting

```python
import matplotlib.pyplot as plt

x = [1, 2, 3, 4]
y = [10, 20, 25, 30]

plt.plot(x, y)
plt.show()
```

## Formatting the Plot

You can add titles, labels, and legends.

```python
plt.plot(x, y, label='Line 1')

plt.title("Simple Plot")
plt.xlabel("X Axis")
plt.ylabel("Y Axis")
plt.legend()

plt.show()
```

## Common Plot Types

### Scatter Plot

```python
plt.scatter(x, y)
plt.show()
```

### Bar Chart

```python
categories = ['A', 'B', 'C']
values = [10, 20, 15]

plt.bar(categories, values)
plt.show()
```

### Histogram

```python
import numpy as np

data = np.random.randn(1000)
plt.hist(data, bins=30)
plt.show()
```

## Saving Figures

```python
plt.savefig("my_plot.png")
```

[[programming/python/python]]