Tableau Playbook - 饼图
介绍
Tableau 是当今最流行的交互式数据可视化工具。它提供了各种各样的图表,可让您轻松有效地探索数据。本系列指南 - Tableau Playbook - 将介绍 Tableau 中各种常见图表。本指南将重点介绍饼图。
在本指南中,我们将从示例图表开始,介绍其概念和特征。通过分析真实数据集:Rossmann Store Sales,我们将逐步学习如何构建饼图。同时,我们将从 Tableau 可视化中得出一些结论。
入门
例子
以下是何时使用饼图 - 最佳实践中的一个饼图示例。此示例比较了好的饼图和坏的饼图,然后引出了饼图的最佳实践,例如:
- 避免分成太多片。
- 切勿使用 3D 饼图。
- 在相邻标签上显示类别比在图例中显示更好。
概念与特征
饼图是商业和数据新闻中最常用的图表之一。它们用于直观地展示部分与整体的关系。
那么,饼图为何如此受欢迎呢?我认为有以下几个原因:
- 饼状图是最直观、简洁、易懂的图表,连名字都一目了然,对受众来说没有任何学习成本。
- 与它的变体(例如径向条形图)相比,它的构建更加容易且更快。
- 与条形和线形相比,它具有更好的视觉吸引力。这篇文章为什么我们觉得圆形如此美丽解释了人们为什么喜欢圆形。
具体来说,在 Tableau 中,饼图用于显示维度中的比例或百分比值。要创建饼图,我们需要一个维度和一个度量。Tableau 支持另一个度量显示为“大小”,以便在一组饼图标记中进行比较,但不建议这种用法。
反对声音
在所有常见的图表中,饼图是反对声音最多的一个。
有一句名言:
朋友不会让朋友使用饼图。
Robert Curtis从感知局限性的角度解释了饼图的天然缺陷:
There are certain attributes that are intuitive and obvious to the human eye, such as spatial position, color, and length. We are not as good at noticing area and angle, and those just so happen to be the two main aspects of a pie chart.
According to the opinion of Ryan Sleeper on Don't Use Pie Charts:
The pie chart's primary limitation is that people are much better at comparing lengths and heights, as you would see in a bar or line chart than they are at comparing areas within a pie.
Further, the long tail results, or the thinner pieces of a pie, tend to become unreadable.
Pie charts are also a very poor vehicle for communicating changes over time.
He lists three main shortcomings of a pie chart. From that, we can summarize the best practice to build a pie chart:
- Limit to five slices. Because thinner and long-tail slices become unreadable and uncomparable. But I want to point out, even with few slices, the comparison is not as precise as a bar chart, which can reflect the multiple relationship or size relationship when the two are close.
- Only use the pie chart to show comparisons at one point in time. If you need to analyze time series data, turn to a line or bar chart. This is not the domain in which it excels.
- For a pie chart, high quality labels are essential. Because the information conveyed by pie shape alone is not enough and is imprecise. Usually, we need labels to flag the categories, proportions, and values.
- It is a good practice to sort the slices, which makes a pie chart more clear for comparison.
Dataset
In this guide, we use the Rossmann Store Sales dataset from this Kaggle Competition. Thanks to Rossmann and Kaggle for this dataset.
This dataset contains three-year sales data for 856 stores in Rossmann. Store sales are influenced by many factors, including promotions, competition, school and state holidays, seasonality, and locality.
I have done the data wrangling and feature engineering for this dataset. You can download my version from Github for a better exploratory data analysis.
Practice
We will build an ordinary pie chart to analyze the composition of sales by StoreType.
As a standard chart, we can click on Show Me and see the request for the pie chart.
For pie charts, try 1 or more Dimensions, 1 or 2 Measures.
正如我们在“Show Me”选项卡中看到的,要构建饼图,我们至少需要一个维度和一个或两个度量。因此,我们按住 Control键(在 Mac 上为Command键)多次选择“StoreType”和“Sales”,然后在“Show Me”中选择“饼图” 。Tableau 将自动生成原始饼图。第二个度量将显示为Size。如果没有提供,则使用第一个度量。
或者,我们可以手动构建饼图:
- 选择饼图作为标记类型。
- 将“StoreType”拖入标记-颜色。
- 将“销售额”拖到“标记-角度”中,这将告诉 Tableau 如何切分这个“饼”。
- 将“销售额”拖到标记-大小中。这是可选步骤。因为我们只使用一个维度,并且我们不打算显示一段时间内的销售额。即使有大小,饼图在时间序列分析方面也很弱,我们之前已经讨论过这一点。
切换到整个视图以获得更好的可视化效果。
对切片进行排序以便进行更清晰的比较。
在颜色中右键单击“StoreType” ,然后单击排序...按字段降序排序。选择“销售额”字段并确保“总计”为聚合。
优化这个饼图:
- 对于非透明的切片,我们最好添加白色边框效果,以提供干净的分离:单击颜色,展开效果中的边框并选择白色。
目前版本中Tableau还不支持调整边框的粗细。
展开“Size Card”并滑动至更合适的尺寸。
添加时间过滤器,观察不同时间点的数据。将“日期”拖入过滤器,过滤“年份”。在过滤器列表中勾选所有年份。
右键单击“YEAR(Date)”,然后单击“显示过滤器” 。
将过滤器图例转换为单值(列表)。
添加格式良好且信息丰富的标签,我们之前已经讨论过其重要性。
按住Control键(在 Mac 上为Command键),并将“StoreType”和“SUM(Sales)”两次拖入Marks - Label中。
右键单击第一个“SUM(销售额)”,然后选择“快速表格计算” -> “总额百分比”。
将第一个“SUM(Sales)”格式化为百分比,并将小数位数设置为 1。
将第二个“SUM(Sales)”格式化为货币,并将小数位数设置为 0。
展开标签卡,点击文本按钮,编辑标签,编辑如下:
<商店类型>:<总金额(销售额)的百分比> <SUM(销售额)>
将字体大小设置为 10,颜色设置为匹配标记颜色,并设置为 粗体。
在某些情况下,我们可能更喜欢将标签放在里面。根据Tableau 的这个线程,对于 Tableau 10.5 及更高版本,我们可以选择一个特定的切片并将其标签拖到里面。对于此版本,请记住将标签的颜色更改为白色。
分析:
上面的饼图展示了按 StoreType 分组的销售额分布情况,我们可以直观的看出某个 StoreType 占比是多还是少,a 贡献了超过一半的销售额,而 b 贡献的销售额非常少。
饼图配合信息丰富的标签,弥补了对比不准确的不足,如果追求更准确的数据,可以参考标签。
替代方案
既然饼图有这么多的缺点,就必须要思考 B 计划。针对上面的饼图,我构建了一系列替代方案。它们各有特色,适用于不同的场景。
免责声明:本内容来源于第三方作者授权、网友推荐或互联网整理,旨在为广大用户提供学习与参考之用。所有文本和图片版权归原创网站或作者本人所有,其观点并不代表本站立场。如有任何版权侵犯或转载不当之情况,请与我们取得联系,我们将尽快进行相关处理与修改。感谢您的理解与支持!
请先 登录后发表评论 ~