Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Data Visualizations with Python

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.

Learning Objectives

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.

Learning Path

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.

Additional Folders and Files

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.

Setup

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.

1. Create the Repository from the Template

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.


2. Add Collaborators (Pairs/Groups Only)

If working with teammates:

  1. Open the repository on GitHub
  2. Go to Settings → Collaborators
  3. Add your teammates as collaborators
  4. Share the repository link with your team

Teammates should accept the invitation before continuing.


3. Clone the Repository

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.


4. Move into the Project Folder and Install Dependencies

This installs all dependencies and creates a virtual environment in .venv/.

cd <repo-name>
uv sync

5. Set up your database credentials

The 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 .env

Open .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.


6. Open the Notebooks

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.

My work

  • 2 - Plotting Intro: all three "Try it yourself" tasks solved (side-by-side histograms, the four catplot kinds compared, an interactive px.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", needs kaleido) 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.

References & Further Reading

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages