A hands-on module on data visualization in Python. You will work through Matplotlib, Seaborn, and Plotly, learn when to reach for exploratory versus explanatory charts, pull data from a SQL database, and build a stakeholder-ready set of plots from the 2020 Kaggle Data Science Survey. The Palmer Penguins dataset is used for the early lessons.
By the end of this repository, you should be able to:
- Create visualizations with Matplotlib, Seaborn, and Plotly.
- Explain when to use exploratory versus explanatory visualizations.
- Fetch data from a SQL database and prepare it for plotting.
- Choose the right chart type for a given data type and question.
- Polish a chart into a clear, audience-ready explanatory visualization.
The lessons build on each other in order:
| File / Folder | Description |
|---|---|
| 1 - Exploratory vs Explanatory | Reading on the two purposes of visualization and the explore, refine, polish workflow. |
| 2 - Plotting Intro | A tour of Matplotlib, Seaborn, and Plotly with diverse chart types and checkpoints, using the Palmer Penguins dataset. |
| 3 - Fetching the Data | Connect to a PostgreSQL database with psycopg2 and SQLAlchemy, query it, and export to CSV. |
| 4 - Visualization Exercise | The main assignment: a stakeholder-driven challenge on the 2020 Kaggle survey where you build at least one plot each with Matplotlib, Seaborn, and Plotly. |
| 5 - Fantastic Charts | A worked gallery from minimal to publication-styled charts across all three libraries, with a quick-reference appendix. |
| File / Folder | Description |
|---|---|
| Data | Datasets used by the notebooks (for example, penguins_clean.csv). |
| Assets | Supporting images and exported charts for the lessons. |
| Solutions | Worked solutions to the exercises in the notebooks. |
| Kaggle Survey 2020 Methodology | Methodology for the 2020 Kaggle survey dataset. |
| Kaggle Survey 2020 Answer Choices | Answer choices reference for the Kaggle survey questions. |
| pyproject.toml | Project configuration and dependencies. |
| uv.lock | Dependency lock file. |
Note
Throughout these steps, text in angle brackets like <repo-name> is a placeholder. Replace it, including the < > brackets, with your own value. For example, cd <repo-name> becomes cd ds-visualisation.
Click Use this template on GitHub.
When creating the repository:
- Set yourself as the Owner
- Choose a repository name
- Disable Include all branches
- Click Create repository
Important
If you are working in pairs or groups, only one person should complete this step.
If working with teammates:
- Open the repository on GitHub
- Go to Settings → Collaborators
- Add your teammates as collaborators
- Share the repository link with your team
Teammates should accept the invitation before continuing.
Copy the SSH URL from the Code button on GitHub, then run:
git clone <copied-ssh-url>The copied SSH URL will look like [email protected]:<your-username>/<repo-name>.git.
This installs all dependencies and creates a virtual environment in .venv/.
cd <repo-name>
uv syncThe Fetching the Data notebook connects to a PostgreSQL database. Copy the example file, then fill in the values your coaches give you:
cp .env.example .envOpen .env and replace the placeholders (USER_DB, PASSWORD, and the host) with your own credentials.
Caution
Never commit .env: it holds secrets and is already git-ignored. Only .env.example, with placeholders, belongs in the repository.
Note
Open VS Code from the project root so it automatically detects the environment created by uv sync.
Launch VS Code in the project root:
code .Then open a notebook and select the Python environment created by uv sync as the kernel.
- 2 - Plotting Intro: all three "Try it yourself" tasks solved (side-by-side histograms, the four
catplotkinds compared, an interactivepx.box); the checkpoint answers were already in the lesson. - 3 - Fetching the Data: run against the course PostgreSQL database (20,036 rows) and exported to
data/kaggle_survey.csv. The host name is no longer printed. - 4 - Visualization Exercise: every checkpoint answered and every challenge plotted: salary box plot (Seaborn), gender by country (Plotly), recommended languages overall (Seaborn) and by role as shares (Plotly), and my own question, company size vs ML adoption (Matplotlib).
- 5 - Fantastic Charts: run top to bottom.
- Plotly charts are saved as static PNG pictures (
pio.renderers.default = "png", needskaleido) so the notebooks stay small. Delete that line to get interactive charts back. - Notebooks 2 and 3 started from my own first run (September 2026); Claude finished the exercises in a delegated pass on 2026-11-25.
- Python Plotting With Matplotlib (Real Python): A thorough walkthrough of Matplotlib's figure and axes model.
- Seaborn user guide and tutorial: The official Seaborn tutorial covering statistical plots and styling.
- Plotly Python Graphing Library: Official documentation for Plotly's interactive charts.
- Jupyter Notebooks in VS Code: How to run and debug notebooks inside VS Code.
- From Data to Viz: A decision tree for picking the right chart type, with common caveats to avoid.
- The Python Graph Gallery: Hundreds of reproducible chart examples in Matplotlib, Seaborn, and Plotly.