人们在电子表格中创建的最常见的图表类型之一是折线图 ,无论是Excel还是Google 表格。(Google Sheets)
折线(Line)图很容易创建,尤其是从一组数据中创建,但您也可以从两组或更多组中创建它们。这将在同一个图表上生成几条线。
在本文中,您将学习如何在Google 表格(Google Sheets)中制作折线图,无论您是使用一组数据还是多组数据。
在Google表格中制作单线图(Single Line Graph)
让您的数据用于创建图表的最简单格式是两列。一列将用作您的 x 轴值,另一列将成为您的 y 轴值。
数据是输入到这些单元格中还是其他电子表格计算的输出中(output of other spreadsheet calculations)都没有关系。
采取以下步骤来创建您的折线图。
1. 选择两列,一直到最后一行数据。
2. 选择Google 表格(Google Sheets)菜单中图标行右侧的图表图标。这将使用您选择的数据在您的工作表中自动生成图表。
Google 表格(Google Sheets)足够智能,可以根据您的列标题创建图表标题。它还将沿 x 轴的第一列放置正确的标签,将沿 y 轴的第二列放置有自己的标签。
在Google表格中制作多线图(Graph)
用多组数据在Google Sheets(Google Sheets)中制作折线图,过程大致相同。您需要将数据布置在多列中,再次将 x 轴数据放在最左边的列中。
要从此数据创建折线图:
- 选择(Select)所有三列直到最后一行数据。
- 选择菜单中图标栏右侧的图表图标。
和以前一样,这将自动生成多类图。这一次,您将看到第二列和第三列数据在图表中显示为两条线(两个系列)。
请注意(Note),以下所有内容都是自动生成的:
- 图表(Graph)标题来自第二列和第三列的标题。
- 系列(Series)标签也来自列标题。
- X 轴是从第一列数据生成的。
- Y 轴是从第二列和第三列数据的范围生成的。
如您所见,该图是单尺度的。这意味着最大和最小范围将默认为足够宽的范围,以便两个系列的数据都可以显示在一个图表上。
好消息是您不会拘泥于默认图表设置。可以对其进行自定义,使其看起来完全符合您的要求。
在Google表格中格式化折线图(Line Graph)
要更新图表的外观,请将鼠标悬停在其上,您会在右上角看到三个垂直点。
选择点,然后从下拉菜单中选择编辑图表。(Edit chart)
电子表格右侧将出现一个窗口。您可以探索两个选项卡。一个是设置(Setup),另一个是自定义(Customize)。
选择设置(Setup),您将看到多种其他图表样式可供选择。
您会看到几种折线图样式,您还可以将图表更改为其他样式,例如条形图、饼图,甚至是多种样式的组合。
例如,您可以选择组合折线图和条形图,它将使用一列作为线条,另一列作为条形。每种类型的图表都有自己的用途,具体取决于您要可视化的数据以及您希望如何比较数据。
自定义部分
要格式化您创建的折线图,请选择自定义(Customize)选项卡。
在第一部分中,您将看到图表样式(Chart style)选项。您可以使用不同的布局选项。最常见的一个是Maximize,它创建了两组数据都适合的最小规模。
这是一种在不丢失任何数据集的情况下尽可能放大数据的方法。
其他选项包括:
- 平滑(Smooth):在折线图中应用平滑函数以减少数据中的噪声。
- 最大化(Maximize):减少填充和边距。
- 绘制空值(Plot null values):如果有空单元格(空值),选择此项将绘制它们,在有空值的行中创建小中断。
- 比较模式(Compare mode):当您将鼠标悬停在线条上时显示数据。
系列部分
下一个要了解的重要部分是Series。
您可以在此处调整代表单个数据点的图标(从列表中选择任何形状)。您还可以调整这些图标的大小和轴线粗细。
在下方,您还会看到向Google 表格(Sheets)折线图添加数据条、数据标签和趋势线的选项。
水平(Horizontal)和垂直轴部分(Vertical Axis Sections)
使用水平轴(Horizontal axis)和垂直轴(Vertical axis)部分调整每个轴上的内容,例如:
- 标签字体和大小
- 标签格式(粗体或斜体)
- 轴文本颜色
- 是否(Whether)将标签本身视为文本
- 显示(Show)轴线或使其不可见
- 对每个轴刻度应用一个因子
- 应用对数刻度
- 如果尚未在数据中应用数字格式,请调整数字格式
当然,您还会看到仅针对 y 轴刻度手动设置最大和最小限制的选项。
在 Google 表格中制作折线图
当您在Google Sheets中制作折线图时,它会自动与您的数据显示在同一张纸上,但您可以复制折线图并将其粘贴到它自己的另一个工作表选项卡中。它仍会显示原始选项卡中的源数据。
您可能很想在 Excel 中以图形或图表的形式绘制数据(plot data in graphs or charts in Excel)。但是 Google 表格中的折线图比Google(Google Sheets)表格(Google Sheets)中的创建和自定义要简单得多。选项很简单,定制更直观。因此,如果您需要以折线图格式绘制任何数据,请先在Google 表格(Google Sheets)中尝试。
How to Make a Line Graph in Google Sheets
One of the most common types of graphs people create in spreadshеets, whether it’s Excеl or Google Sheets, is the line graph.
Line graphs are easy to create, especially from one set of data, but you can also create them from two or more sets. This will generate several lines on the same graph.
In this article you’ll learn how to make a line graph in Google Sheets, whether you’re working with one set of data or several.
Make a Single Line Graph in Google Sheets
The easiest format to have your data for creating a graph is two columns. One column will serve as your x-axis values, and the other will become your y-axis values.
It doesn’t matter if the data is typed into these cells or the output of other spreadsheet calculations.
Take the following steps to create your line graph.
1. Select both columns, all the way down to the last row of data.
2. Select the chart icon toward the right side of the row of icons in the Google Sheets menu. This will automatically generate the chart in your sheet using the data you selected.
Google Sheets is intelligent enough to create the chart title from your column headers. It also places the first column along the x-axis with the correct label, and the second column along the y-axis with its own label.
Making a Multi-Line Graph in Google Sheets
To make a line graph in Google Sheets from multiple sets of data, the process is roughly the same. You’ll need to lay out the data in multiple columns, again with the x-axis data in the leftmost column.
To create the line graph from this data:
- Select all three columns down to the last row of data.
- Select the chart icon at the right side of the icon bar in the menu.
Just as before, this will automatically generate the multi-like graph. This time you’ll see the second and third column of data appear as two lines (two series) in the graph.
Note all of the following are generated automatically:
- Graph title comes from the headers for the second and third column.
- Series labels also come from the column headers.
- X-axis is generated from the first column data.
- Y-axis is generated from the range of the second and third column data.
As you can see, the graph is a single-scale. This means the max and min range will default to a wide enough range that both series of data can be displayed on the one graph.
The good news is that you aren’t stuck to the default graph settings. It’s possible to customize it so that it looks exactly the way you want it to.
Formatting a Line Graph in Google Sheets
To update the appearance of your chart, hover your mouse over it and you’ll see three vertical dots in the upper right corner.
Select the dots, and select Edit chart from the dropdown menu.
A window will appear on the right side of the spreadsheet. There are two tabs you can explore. One is Setup and the other is Customize.
Select Setup and you’ll see a variety of other chart styles to choose from.
You’ll see several line chart styles, and you can also change the chart to something else like bar, pie, or even a combination of several styles.
For example you can choose a combination line and bar chart, which will use one column for the line and another for the bars. Each type of chart has its own purpose, depending on what data you’re visualizing and how you want to compare the data.
The Customize Section
To format the line graph you’ve created, select the Customize tab.
In the first section you’ll see the Chart style option. You can play around with the different layout options. One of the more common ones is Maximize, which creates the smallest scale possible that both sets of data will fit into.
This is a way to zoom in on your data as much as possible without losing either data set.
Other options include:
- Smooth: Apply a smooth function within the line chart to reduce noise in your data.
- Maximize: Reduces padding and margins.
- Plot null values: If there are empty cells (null values) selecting this will plot them, creating small breaks in the line where there are null values.
- Compare mode: Displays the data when you hover over the line.
The Series Section
The next important section to know about is Series.
This is where you can adjust icons that represent individual data points (choose any shape from the list). You can also adjust the size of those icons and axis line thickness.
Lower down you’ll also see options to add data bars, data labels, and a trendline to your Google Sheets line chart.
Horizontal and Vertical Axis Sections
Use the Horizontal axis and Vertical axis sections to adjust things on each axis like:
- Label font and size
- Label format (bold or italics)
- Axis text colors
- Whether to treat labels themselves as text
- Show an axis line or make it invisible
- Apply a factor to each axis scale
- Apply a logarithmic scale
- Adjust the number format if it hasn’t been applied in the data
Of course you’ll also see the option to manually set the max and min limits only for the y-axis scale.
Making Line Charts in Google Sheets
When you make a line chart in Google Sheets, it automatically appears on the same sheet as your data, but you can copy the line chart and paste it into another sheet tab of its own. It’ll still display the source data from the original tab.
You might be tempted to plot data in graphs or charts in Excel. But line charts in Google Sheets are much simpler to create and customize than in Google Sheets. Options are straightforward and the customization is much more intuitive. So if you ever need to plot any data in a line graph format, try it in Google Sheets first.