Day 104 — 数据可视化 | 图解
Matplotlib 对象模型
┌──────────────────────────────────────────────────────┐
│ Figure(画布) │
│ │
│ ┌────────────────────┐ ┌────────────────────┐ │
│ │ Axes[0,0] │ │ Axes[0,1] │ │
│ │ │ │ │ │
│ │ ┌──┐ ┌──┐ │ │ ┌──┐ │ │
│ │ │ │ │ │ │ │ │ │ ┌──┐ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ └──┘ └──┘ │ │ └──┘ └──┘ │ │
│ │ X轴 Y轴 │ │ │ │
│ └────────────────────┘ └────────────────────┘ │
│ │
│ ┌────────────────────┐ ┌────────────────────┐ │
│ │ Axes[1,0] │ │ Axes[1,1] │ │
│ │ │ │ │ │
│ └────────────────────┘ └────────────────────┘ │
│ │
│ title() ─── suptitle() │
└──────────────────────────────────────────────────────┘
图表选择决策树
你想展示什么?
│
┌───────┴───────┐
│ │
分布数据 分类数据
│ │
┌───┴───┐ ┌───┴───┐
│ │ │ │
单变量 多变量 对比 占比
│ │ │ │
hist pair bar pie
kde heatmap box count
Seaborn vs Matplotlib 工作流
Matplotlib(手动控制):
数据准备 → 创建 Figure → 创建 Axes → 调用绑图 → 样式美化 → 保存
Seaborn(自动美化):
数据准备 → sns.xxxplot(data=df, x=, y=, hue=) → 微调 → 保存