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

第 9 章 折线图 折线图、独立坐标轴和日期层次结构

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

在上一章中,我分享了在 Tableau 中制作条形图的五种不同方法。本章将向您介绍如何构建另一种重要的数据可视化:折线图。 虽然我喜欢用 Tableau 构建各种花哨的可视化效果,但归根结底,条形图和折线图是最有效的两种可选方法。同时,我们还将讨论一些相关主题,包括日期层次结构和独立坐标轴,以便您掌握这种基础图形。

如何在 Tableau 中制作折线图

折线图类似于 Tableau 中的条形图,您可以查看一个或多个度量值,并可选择 按一个或多个维度对其进行 "切分"。条形图和折线图的重要区别在于折线图应包含时间元素。 让我们使用 "样本 - 超级市场 "数据集,以 "订单日期 "作为时间元素来绘制折线图。

首先,使用第 35 章中讨论的五种方法中的任何一种创建一个条形图,将 SUM(Sales) 添加到行列搁架中。我将直接双击销售额度量来启动视图。

此时,您也可以双击时间元素(订单日期)来开始绘制折线图,但有一个更好的方法。 与度量一样,日期也有聚合,可以用作连续或离散字段。对这两种分类的选择会影响可视化效果。幸运的是,如果不双击订单日期维度,而是右键单击并将其拖动到列架,就可以轻松查看所有选项。在 Tableau 生成可视化之前,您将看到以下选项:

prta 0901

正如您所看到的,每个选项旁边都有一个蓝色或绿色图标。请记住,Tableau 中的蓝色颜色编码表示离散,而绿色颜色编码表示连续。选择离散还是连续选项应根据要创建的可视化类型而定。比方说,我们想查看随时间变化的连续趋势,这意味着我们可以暂时忽略蓝色选项。

下一个选择是连续趋势的粒度。 这就是所谓的日期部分,包括年、季度、月、周和日等选项。在本分析中,我们希望看到每月的长期趋势。考虑到这两个要求,我们知道应该选择带绿色图标的选项,其聚合度为月,也就是从底部开始的第四个选项。做出这一选择后,折线图看起来就像这样了:

prta 0902
备注

每个数据点上的小圆圈称为 "标记",可以通过单击 "颜色标记卡 "并选择 "效果 "下的 "标记:"选项之一来添加。

Tableau 中的独立坐标轴

现在,只需将上一节创建的折线图拖到列或行货架上,并将其拖到视图上的连续字段(当前为 MONTH(订单日期)或 SUM(销售额))前面,就可以 对其进行切分。为了演示在 Tableau 中坐标轴如何跨多个列或行工作,我将把出货模式维度拖到行货架上:

prta 0903

请注意,默认情况下,每一行共享相同的坐标轴范围,从 0 美元到大约 60,000 美元,这是所有四种船舶模式中最大的范围。这种默认设置(各坐标轴共享相同的范围)很有帮助,因为它提供了四行之间的苹果对苹果比较。不过,要看清每一行的趋势可能比较困难。如果希望四个坐标轴有各自的坐标轴范围,请右键单击任一坐标轴并选择 ...

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

数据科学实战手册(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
Python深度学习从原理到应用

Python深度学习从原理到应用

Posts & Telecom Press, Valentino Zocca
Python数据分析(第2版)

Python数据分析(第2版)

Posts & Telecom Press, Armando Fandango

Publisher Resources

ISBN: 9798341657137