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

第 21 章 如何制作双轴组合图 如何制作双轴组合图

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

双轴组合图表或组合图表是一种有效的图表类型,可用于显示相关信息,同时通过组合视图节省空间。 这种图表类型使用一个共享轴(如日期 x 轴)和两个独立轴(如两个不同测量值的 y 轴)创建。本章将向您展示如何在 Tableau 中制作双轴组合图表,查看按年份和产品类别划分的销售额和折扣。

如何在 Tableau 中制作双轴组合图

在开始之前,让我们来看看最终产品的外观:

prta 2101
  1. 绘制其中一个测量值的图表。

    第一步是为其中一个测量值绘制图表。从两个指标中的哪一个开始并不重要,但您选择的第一个指标将始终构成左侧的 Y 轴或底部的 X 轴(取决于图表的方向)。让我们从制作按年份划分的销售额折线图开始。要创建第一个图表,请将订单日期字段拖动到列层,并将年份连续聚合。然后将销售额字段拖到行层。此时,视图如下:

    prta 2102
  2. 将第二个测量值拖到相反的轴上。

    要创建双轴图表,您需要将第二个测量值拖动到与第一个测量值相反的轴上。在我的例子中,销售额位于左 Y 轴上。我想在视图中添加 "折扣 "指标,因此要把它拖到右 Y 轴的位置。当我接近对轴时,Tableau 会用虚线提示我可以在哪里下放测量值:

    prta 2103

    一旦我将字段放到相反的坐标轴上,Tableau 就会生成一个双坐标轴图表。请注意,此时的图表是双轴图表,但不是双轴组合图表。组合图表的名称来自于标记类型的组合,而到目前为止,我们只有一种标记类型(线):

    prta 2104
  3. 更改其中一种标记类型,创建双轴组合图表。

    当第二个测量值投放到视图上时,不仅字段出现在行层上,而且还生成了两个新的标记层。第一个新标记层 "全部 "影响视图上的所有标记,第二个新标记层用于右侧 Y 轴上的标记。 现在,每个测量值的标记都可以独立编辑,从而可以在视图上显示标记类型的组合

    让我们将销售额字段的标记类型更改为条形图,并将折扣的标记类型保留为折线图。方法是单击 SUM(销售额)的标记层,将标记类型从自动改为条形图。此时,视图如下:

prta 2105

一些补充想法

  • 我决定绘制第一张图,即按连续年份绘制的销售额图,因为它的目的是显示随时间变化的连续(即按时间顺序排列)趋势。很多人问,既然年份是连续的,为什么柱形图这么瘦(10 ...

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