# Python Seaborn Module

Seaborn is a Python data visualization library based on matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics. It integrates closely with pandas data structures.

## Installation

```bash
pip install seaborn
```

## Importing the Module

```python
import seaborn as sns
import matplotlib.pyplot as plt
```

## Basic Plotting

Seaborn comes with built-in datasets which are useful for practice.

```python
# Load an example dataset
tips = sns.load_dataset("tips")
```

### Scatter Plot (`scatterplot`)

```python
sns.scatterplot(data=tips, x="total_bill", y="tip", hue="time")
plt.show()
```

### Line Plot (`lineplot`)

```python
sns.lineplot(data=tips, x="total_bill", y="tip")
plt.show()
```

### Histogram (`histplot`)

```python
sns.histplot(data=tips, x="total_bill", kde=True)
plt.show()
```

### Box Plot (`boxplot`)

```python
sns.boxplot(data=tips, x="day", y="total_bill")
plt.show()
```

### Heatmap (`heatmap`)

Heatmaps are great for visualizing correlation matrices.

```python
# Calculate correlation matrix (only numeric columns)
corr = tips.corr(numeric_only=True)

sns.heatmap(corr, annot=True, cmap="coolwarm")
plt.show()
```

### Pair Plot (`pairplot`)

Plot pairwise relationships in a dataset. This creates a grid of Axes such that each variable in data will by shared in the y-axis across a single row and in the x-axis across a single column.

```python
sns.pairplot(tips, hue="sex")
plt.show()
```

## Themes

Seaborn makes it easy to change the overall look of your plots using `set_theme`.

```python
sns.set_theme(style="darkgrid")
# Available styles: darkgrid, whitegrid, dark, white, ticks
```

[[programming/python/python]]