Code and examples from our Python Data Visualization course.
Have you ever been confused by all the different python plotting libraries? Have you tried to make a "simple" plot and gotten stuck and been unable to move forward? Do you want to make sophisticated, interactive data visualizations in python? If you answer yes, to any of these questions, then this course is for you.
The python data visualization landscape has many different libraries. They are all powerful and useful but it can be confusing to determine what works best for you. This course is unique because you will learn about many of the most popular python visualization libraries. You will start by learning how to use each library to build simple visualizations. You will also explore more complex usage and identify the scenarios where each library shines.
By the end of this course, you will have a basic working knowledge of how to visualize data in python using multiple libraries. You will also learn which library is best for you and your coding style. Along the way, you'll learn general visualization concepts to make your plots more effective.
In addition to the overview material, we will cover some of the more complex, interactive visualization dashboard technologies.
In this course, you will:
- Review the python visualization landscape
- Explore core visualization concepts
- Use matplotlib to build and customize visualizations
- Build and customize simple plots with pandas
- Learn about seaborn and use it for statistical visualizations
- Create visualizations using Altair
- Generate interactive plots using the Plotly library
- Design interactive dashboards using Streamlit
- Construct highly custom and flexible dashboards using Plotly's Dash framework
View the full course outline.
Developers and Data Analysts that have some experience with python but have not developed a competency in a python visualization library. This course is also helpful for those that feel restricted by their current plotting tools and wish to explore other options.
Note: All software used during this course, including editors, Python language, etc., are 100% free and open source. You won't have to buy anything to take the course.
Data sciense is one of the hottest topic of the year and data visualization is a core skillset needed to properly communicate your results and discoveries. Take this course to get good at a wide variety of modern Python-based visualization libraries.
项目提供统一启动入口 launcher.py,自动检查依赖并启动各类示例:
# 1. 安装依赖
pip install -r requirements.txt
# 2. 查看所有可用示例
python launcher.py list
# 3. 交互式选择(推荐)
python launcher.py
# 4. 或直接启动指定示例
python launcher.py run dash-full # 启动完整 Dash 应用
python launcher.py run st-1 # 启动 Streamlit 示例
python launcher.py run nb-ch5 # 打开 Notebook启动前可单独执行环境检查,明确区分四类问题:
# 检查所有示例的环境就绪状态
python launcher.py check
# 检查指定示例
python launcher.py check dash-1检查结果会按 缺依赖 / 缺数据文件 / 缺入口脚本 / 缺启动器 四类分别列出,并给出对应解决方法。
启动入口由两个 JSON 配置文件驱动,职责分离、互不干扰:
| 文件 | 管什么 | 什么时候改 |
|---|---|---|
examples_manifest.json |
示例列表 — 有哪些示例、叫什么、依赖哪些包/数据 | 新增或删除一个示例时 |
launch_schema.json |
类型启动规则 — 每种 type 用什么命令、什么参数、什么工作目录、有哪些 fallback |
改变某类示例的启动方式时(如换一个 notebook 启动器) |
新增示例只改 examples_manifest.json,不需要动 launch_schema.json,也不需要改 launcher.py。
在 examples_manifest.json 中追加一条记录。三种类型的最小配置如下:
Dash 应用
"dash-your-id": {
"type": "dash",
"file": "your_dash_app.py",
"title": "简短标题",
"desc": "一句话描述",
"data_files": ["EPA_fuel_economy_summary.csv"],
"deps": ["pandas", "dash", "plotly"]
}Streamlit 应用
"st-your-id": {
"type": "streamlit",
"file": "your_streamlit_app.py",
"title": "简短标题",
"desc": "一句话描述",
"data_files": ["EPA_fuel_economy_summary.csv"],
"deps": ["pandas", "streamlit", "plotly"]
}Jupyter Notebook
"nb-chX-Y": {
"type": "notebook",
"file": "chX-exercise-Y.ipynb",
"title": "第 X 章 练习 Y",
"desc": "一句话描述",
"data_files": ["EPA_fuel_economy.csv"],
"deps": ["pandas", "numpy", "matplotlib"]
}字段说明:
| 字段 | 必填 | 说明 |
|---|---|---|
type |
✅ | dash / streamlit / notebook / script,对应 launch_schema.json 中的启动规则 |
file |
✅ | 脚本文件名,相对于 code/ 目录 |
title |
✅ | 显示在列表中的简短名称 |
desc |
✅ | 补充说明 |
data_files |
✅ | 依赖的数据文件名(空数组为无依赖),相对于 code/data/raw/ |
deps |
✅ | 需要检查的 Python 包列表(空数组为无依赖) |
示例 ID 命名约定:dash-* / st-* / nb-chX-Y(第X章第Y题)。
如果需要支持一种全新的示例类型(例如 bokeh 或 gradio),在 launch_schema.json 中追加一条类型规则:
"bokeh": {
"command": "{python}",
"args_template": ["-m", "bokeh", "serve", "{file}"],
"cwd": "code",
"check_package": "bokeh",
"fallbacks": []
}然后在 examples_manifest.json 中使用 "type": "bokeh" 即可,无需修改任何 Python 代码。
- Chapter 3 Matplotlib Data Visualization
- Chapter 3 Matplotlib Data Visualization
- Chapter 3 Matplotlib Data Visualization
- Chapter 4 Pandas Data Visualization
- Chapter 4 Pandas Data Visualization
- Chapter 5 Seaborn Data Visualization
- Chapter 5 Seaborn Data Visualization
- Chapter 5 Seaborn Data Visualization
- Chapter 5 Seaborn Data Visualization
- Chapter 6 Altair Data Visualization
- Chapter 6 Altair Data Visualization
- Chapter 6 Altair Data Visualization
- Chapter 7 Ploty Data Visualization
- Chapter 7 Ploty Data Visualization
- Chapter 7 Ploty Data Visualization
- Chapter 7 Ploty Data Visualization
| File | Rows | Cols | Missing |
|---|---|---|---|
AmazonBooks.xlsx |
600 | 7 | 0 |
EPA_fuel_economy.csv |
24,210 | 14 | cylinders:231, displ:230, trany:9 |
EPA_fuel_economy_summary.csv |
24,210 | 16 | cylinders:231, displ:230 |
output/altair/ch06_demo_scatter.html
output/plotly/ch07_demo_bar.html
output/readme/auto_generated_section_artefacts.mdoutput/readme/auto_generated_section_datasets.mdoutput/readme/auto_generated_section_notebooks.md
项目提供统一的维护命令 maintenance.py,把五项日常检查整合到一个入口,改数据或新增示例后只需跑一次:
# 一键跑所有检查(默认)
python maintenance.py
# 或单独跑某一项
python maintenance.py profile # 刷新数据 profile 缓存 (.metadata_cache/)
python maintenance.py readme # 更新 README 自动生成区块 (output/readme/)
python maintenance.py manifest # 校验 examples_manifest.json 与磁盘一致性
python maintenance.py deps # 检查依赖锁文件 (requirements.txt vs .piptools)
python maintenance.py launcher # 启动器栈自检 (schema + manifest + launcher.py)维护命令的职责分工:
| 子命令 | 检查什么 | 什么时候跑 |
|---|---|---|
profile |
扫描 code/data/raw/ 下的 CSV / Excel,重建 .metadata_cache/*.json(行数、列数、缺失值) |
新增或更新数据文件后 |
readme |
扫描 code/ 下的 notebook 和 output/ 下的产物,重写 output/readme/ 下两个自动生成区块 |
新增 notebook 或输出新产物后 |
manifest |
逐条校验 examples_manifest.json:字段完整、type 在 schema 中、脚本/数据文件存在、无未声明脚本 |
新增示例或改文件名后 |
deps |
对比 requirements.piptools 与 requirements.txt,跑 pip check 检查安装依赖一致性 |
改依赖或换环境后 |
launcher |
校验 launch_schema.json 字段完整、manifest 中 type 使用情况、launcher.py 语法 |
改启动规则或新增 type 后 |
所有子命令的 PASS / WARN / FAIL 会分组打印,最终有任一 FAIL 时退出码为 1。只改了某一类内容时,跑对应的子命令即可;不确定时跑 python maintenance.py(等价于 all)。
