# Plotting in Python with Matplotlib and Seaborn

> Creating clear static charts in Python: Matplotlib's figure and axes model and Seaborn's statistical plotting. Free notes, key concepts, resources and a mini...

Canonical: https://www.internhack.in/roadmaps/tracks/data-analyst/python-viz-static
Last updated: 2026-11-28

Creating clear static charts in Python: Matplotlib's figure and axes model and Seaborn's statistical plotting.

Intermediate · about 6 hours · difficulty 3/5

Learn first: [pandas for Data Analysis](https://www.internhack.in/roadmaps/tracks/data-analyst/pandas-core), [Choosing the Right Chart](https://www.internhack.in/roadmaps/tracks/data-analyst/chart-selection)

Python plotting lets you create charts reproducibly, as part of your analysis code, at any scale.

### Matplotlib: the foundation

- Use the object-oriented style: `fig, ax = plt.subplots(figsize=(8, 4))` then `ax.plot(...)`, `ax.bar(...)`, `ax.set_title(...)`.
- `plt.subplots(2, 3)` gives a grid of axes for small multiples.
- Control ticks, labels and number formats (`matplotlib.ticker`), remove spines, and annotate key points with `ax.annotate`.
- Save with `fig.savefig("chart.png", dpi=200, bbox_inches="tight")`.

### Seaborn: statistical charts fast

- Works directly with tidy DataFrames: `sns.histplot(data=df, x="price", hue="room_type")`.
- Distribution plots (`histplot`, `kdeplot`, `boxplot`, `violinplot`, `ecdfplot`), relationship plots (`scatterplot`, `lineplot`, `regplot`), categorical plots (`barplot`, `pointplot`), and `heatmap`.
- Figure-level functions (`relplot`, `displot`, `catplot`) create faceted small multiples with `col=` and `row=`.
- Seaborn returns Matplotlib axes, so you can fine-tune with Matplotlib.

### Style

Set a theme once (`sns.set_theme(style="whitegrid")`), then apply the design principles from earlier topics: highlight one thing, direct labels, insight titles.

**Pitfall:** Seaborn's `barplot` shows the mean with an error bar by default, not the sum. Know what each function aggregates. Move on when you can produce a publication-ready faceted chart with custom labels in a few lines.

## Key concepts

- **Figure and Axes model**
- **Line, bar, scatter in Matplotlib**
- **Subplots and small multiples**
- **Annotations and formatting**
- **Seaborn distribution plots**
- **Seaborn faceting with relplot and catplot**
- **Themes and styling**
- **plotnine / ggplot-style in Python**

## Mini project

Using the Seaborn 'tips' or Inside Airbnb data, produce a four-chart figure (distribution, trend, category comparison, relationship) with consistent styling and insight titles, saved as a PNG.

## Check yourself

What does sns.barplot show by default, and how would you plot totals instead?

## Free resources

- [Matplotlib user guide](https://matplotlib.org/stable/users/index.html) (Matplotlib)
- [Seaborn tutorial](https://seaborn.pydata.org/tutorial.html) (Seaborn)
- [Kaggle Data Visualization course](https://www.kaggle.com/learn/data-visualization) (Kaggle)

Previous: [Dashboard Design](https://www.internhack.in/roadmaps/tracks/data-analyst/dashboard-design) · Next: [Interactive Charts with Plotly](https://www.internhack.in/roadmaps/tracks/data-analyst/python-viz-interactive)

## More in Visualization: Principles and Libraries

- [Choosing the Right Chart](https://www.internhack.in/roadmaps/tracks/data-analyst/chart-selection)
- [Perception, Colour and Honest Design](https://www.internhack.in/roadmaps/tracks/data-analyst/visual-perception-color)
- [Dashboard Design](https://www.internhack.in/roadmaps/tracks/data-analyst/dashboard-design)
- [Plotting in Python with Matplotlib and Seaborn](https://www.internhack.in/roadmaps/tracks/data-analyst/python-viz-static)
- [Interactive Charts with Plotly](https://www.internhack.in/roadmaps/tracks/data-analyst/python-viz-interactive)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Data Analyst Roadmap](https://www.internhack.in/roadmaps/tracks/data-analyst)
