Skip to Content
实用 Tableau
book

实用 Tableau

by Ryan Sleeper
May 2025
Intermediate to advanced
624 pages
7h 35m
Chinese
O'Reilly Media, Inc.
Content preview from 实用 Tableau

第 45 章 如何制作哑铃图表 如何制作哑铃图表

本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com

Tableau 哑铃图(也称为 DNA 图)是用于说明两个数据点之间变化的另一种可视化选择。 哑铃图的俚语名称来源于其外观,当哑铃图处于水平方向时,其外观类似于砝码,有时也类似于 DNA 链。

我个人很喜欢有一种不落俗套的图表类型,它不是以甜甜圈或华夫饼等美味食物命名的。你甚至可以说哑铃图表是一种健康的替代品......

抛开名称不谈,这是我发现的另一种引人入胜、有效且相对容易在 Tableau 中创建的图表类型。本教程将说明如何通过几个步骤在 Tableau 中制作哑铃图。

如何制作 Tableau 哑铃图

Tableau 哑铃图实际上是双轴组合图,其中一个轴的标记类型为圆形,另一个轴的标记类型为直线。 在本教程中,我们将重新创建此可视化图表,比较样本 - 超级市场数据集中每个子类别的同比销售额:

prta 4501

在 Tableau 中创建哑铃图的第一步是用要可视化的度量和维度创建点阵图。 在本示例中,我将把样本 - 超级市场数据集中的销售额度量放到列层,把子类别维度放到行层。这样就创建了一个按子类别划分的销售额条形图,只需将标记类型从自动改为圆形,就能轻松将其转换为点阵图。

我还将对可视化数据集的最后两年进行过滤,这样每个子类别就只有两个比较点,同时还将按年份给标记着色,以区分哪一年是哪一年。目前,我的视图如下:

prta 4502

请注意,这种图表类型也可以垂直方向创建,方法是调换行和列架上字段的位置,但本教程中我们将坚持使用水平方向。

第二步,也是最后一步,是用销售额度量创建第二个坐标轴,并将其标记类型更改为直线。 要将点阵图转化为双轴组合图,可将销售额度量值拖动到图表顶部附近,与图表底部的销售额坐标轴正对;当出现虚线时,将度量值放到视图上。或者,也可以在列架上放置第二个销售额度量,右键单击第二个药丸,然后选择双轴。右键单击顶部坐标轴并选择同步坐标轴,确保坐标轴始终对齐。

此时,销售额度量的每次出现都有一组标记卡,可以对它们进行独立编辑。导航到 SUM(销售额)的第二组标记卡,将标记类型更改为线条,然后将标记架上的 YEAR(订单日期)维度拖到路径标记卡上:

prta 4503

这样就可以在 Tableau 中绘制出漂亮的哑铃图了。在这里,您可以格式化标记的大小和颜色,右键单击顶轴并取消选择显示标题,即可隐藏顶轴。

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Python深度学习从原理到应用

Python深度学习从原理到应用

Posts & Telecom Press, Valentino Zocca
数据科学实战手册(R+Python)(第2版)

数据科学实战手册(R+Python)(第2版)

Posts & Telecom Press, Prabhanjan Narayanachar Tattar, Tony Ojeda, Sean Patrick Murphy, Sean P Murphy, Benjamin Bengfort, Bengfort Benjamin, ABHIJIT DASGUPTA
C++语言导学(原书第2版)

C++语言导学(原书第2版)

本贾尼 斯特劳斯特鲁普
程序设计导论:Python语言实践

程序设计导论:Python语言实践

罗伯特 塞奇威克, 凯文 韦恩, 罗伯特 唐德罗

Publisher Resources

ISBN: 9798341657137