气泡图

气泡图将第三个定量指标编码为每个点的面积。它确实很有用,但也很容易被滥用:面积比位置更难读取。

请将大小用于三个指标中你最不关心的那一个。


#适用场景

  • 三个度量中,有两个比第三个更重要。

  • 组合视图:投入、影响和成本。

  • 比较规模差异极大的项目。


#数据需要具备的格式

字段

类型

X

定量型

Y

定量型

大小

定量型

颜色

名义型,可选


#一个完整示例

在一张图表中展示投入、影响和团队规模:

气泡图

以下是源代码,您可以将其粘贴到新图表中并进行编辑:

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "description": "Roadmap items: effort, impact and team size",
  "width": 380,
  "height": 280,
  "data": {"values": [
    {"item": "Single sign-on", "effort": 8, "impact": 9, "people": 4, "area": "Platform"},
    {"item": "Bulk export", "effort": 3, "impact": 7, "people": 2, "area": "Apps"},
    {"item": "Dark mode", "effort": 4, "impact": 5, "people": 2, "area": "Apps"},
    {"item": "Audit log", "effort": 6, "impact": 8, "people": 3, "area": "Platform"},
    {"item": "Legacy import", "effort": 9, "impact": 3, "people": 5, "area": "Data"},
    {"item": "Custom themes", "effort": 7, "impact": 2, "people": 3, "area": "Apps"}
  ]},
  "mark": {"type": "circle", "opacity": 0.75},
  "encoding": {
    "x": {"field": "effort", "type": "quantitative", "title": "Effort", "scale": {"domain": [0, 10]}},
    "y": {"field": "impact", "type": "quantitative", "title": "Impact", "scale": {"domain": [0, 10]}},
    "size": {"field": "people", "type": "quantitative", "title": "People"},
    "color": {"field": "area", "type": "nominal", "title": "Area"},
    "tooltip": [{"field": "item"}]
  }
}

#容易让人踩坑的几点

  • 大小应按面积而非半径来解读。若按半径编码,大数值会被夸大四倍。

  • 气泡重叠时需要设置透明度,否则小气泡会被遮住。

  • 为重要的气泡添加标签。包含八个条目的图例相当于一项查找任务。



请根据要解答的问题来选择图表,而不是根据外观。