# Visualization with Matplotlib and Seaborn

> Plotting distributions, relationships and model diagnostics so you see problems in data and models before metrics hide them. Free notes, key concepts,...

Canonical: https://www.internhack.in/roadmaps/tracks/machine-learning/data-visualization
Last updated: 2026-11-28

Plotting distributions, relationships and model diagnostics so you see problems in data and models before metrics hide them.

Beginner · about 6 hours · difficulty 2/5

Learn first: [pandas for Tabular Data](https://www.internhack.in/roadmaps/tracks/machine-learning/pandas)

Plots are how you catch skewed features, outliers, label noise and overfitting curves. Matplotlib is the low-level engine; Seaborn sits on top and makes statistical plots from DataFrames in one line.

### What to learn

- **Matplotlib object API**: `fig, ax = plt.subplots()` and calling methods on `ax`. It scales to multi-panel figures far better than the `plt.` state machine.
- **Distributions**: histograms, KDEs, box and violin plots (`sns.histplot`, `sns.boxplot`).
- **Relationships**: scatter plots, pair plots, correlation heatmaps.
- **Categorical comparisons**: bar and count plots with confidence intervals.
- **ML diagnostics**: learning curves, confusion matrices, residual plots, ROC curves.

### Habits

Always label axes and units, use log scales for heavy-tailed data, and prefer small multiples over cramming ten series on one chart. Interactive tools like Plotly are handy for dashboards but optional here.

**Good enough to move on** when you can produce a one-page EDA figure (distribution, relationship and category panels) for any new dataset in a few minutes.

## Key concepts

- **Figure and Axes API**
- **Distribution plots**
- **Scatter and pair plots**
- **Heatmaps**
- **Diagnostic plots for models**
- **Plotly for interactivity**

## Mini project

Build a 2x3 subplot EDA figure for the Palmer Penguins dataset: species counts, bill length distributions per species, a flipper versus body mass scatter, and a correlation heatmap.

## Check yourself

When would a histogram mislead you where a box plot or ECDF would not?

## Free resources

- [Seaborn tutorial](https://seaborn.pydata.org/tutorial.html) (seaborn)
- [Matplotlib documentation](https://matplotlib.org/stable/) (matplotlib)
- [Kaggle Learn: Data Visualization](https://www.kaggle.com/learn/data-visualization) (Kaggle)

Previous: [pandas for Tabular Data](https://www.internhack.in/roadmaps/tracks/machine-learning/pandas) · Next: [Git for ML Projects](https://www.internhack.in/roadmaps/tracks/machine-learning/git-for-ml)

## More in Python and the Data Workbench

- [Python for Machine Learning](https://www.internhack.in/roadmaps/tracks/machine-learning/python-for-ml)
- [Environments, Packages and Jupyter](https://www.internhack.in/roadmaps/tracks/machine-learning/environments-and-notebooks)
- [NumPy and Array Thinking](https://www.internhack.in/roadmaps/tracks/machine-learning/numpy)
- [pandas for Tabular Data](https://www.internhack.in/roadmaps/tracks/machine-learning/pandas)
- [Visualization with Matplotlib and Seaborn](https://www.internhack.in/roadmaps/tracks/machine-learning/data-visualization)
- [Git for ML Projects](https://www.internhack.in/roadmaps/tracks/machine-learning/git-for-ml)
- [SQL for Pulling Training Data](https://www.internhack.in/roadmaps/tracks/machine-learning/sql-for-data)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Machine Learning Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/machine-learning)
