Visualizing data using charts and graphs can be a great way to understand your data and relationships between the variables in the data.
Moreover, adding a trend line (also called the line of best fit) to the chart can help you gain a deeper understanding of the chart.
In this tutorial I will show you how to add a line of best fit in Google Sheets, to help you gain better insights into your data.
What is a Line of Best Fit?
A trend line, or a ‘line of best fit’ is one that is superimposed on a chart to understand trends within the data.
These lines can help you understand the direction of the data, make forecasts and understand relationships between data elements.
For example, if you look at the scatter chart below, you can somewhat tell how the data points are distributed but it’s hard to tell if there’s an upward or downward trend. It is also a little tough to make proper sense of the distribution.
What happens if I add a trendline to this chart?
Adding a trend line, as shown above, helps bring a lot of things into perspective.
We can now see that the data is moving in an upward direction.
We can also extrapolate the line to make predictions about future data points, and I can tell which data points are outliers, or completely far away from the general trend.
Trend lines can be added to bar, line, column, or scatter charts. In the next section I will show you how to add a trendline in Google Sheets to fit with a scatter chart.
How to Add a Line of Best Fit in Google Sheets
Before I show you how to add a line of best fit, let us first quickly go over how you can create a chart for the data shown below:
In the above image, I have data on the number of times ads were posted and the number of sales made.
To visualize this type of data, a scatter chart would be a great option.
Here’s how you can quickly use this data to create a scatter chart in Google Sheets.
Creating a Scatter Chart in Google Sheets
To create a scatter chart based on our given data, follow the steps below:
- Select the data range, including the column headers. In our case, select the range A1:B22.
- Click on the Insert menu from the menu bar.
- Select the Chart option from this menu.
- You will see a chart displayed on the worksheet and a Chart Editor sidebar on the right side of the window.
- Google usually attempts to predict and recommend a chart depending on your selected data. If the chart displayed is not a scatter chart, then go to step 6. Otherwise, stop here.
- To convert your displayed chart to a scatter chart, select the Setup tab from the Chart Editor and click on the drop-down menu under ‘Chart Type’.
- From the chart options, select “Scatter Chart”, which you should be able to find under the Suggested or Other category.
You should now see a Scatter chart on your worksheet. Next, it’s time to add a line of best fit so you can understand the trends in your data.
How to Find the Line of Best Fit on Google Sheets
There is no Google Sheets line of best fit equation you have to use. You just have to make some customizations to the chart.
The Chart editor sidebar consists of two tabs – Setup and Customize. The Customize tab has different options to help you customize different chart settings.
To add a line of best fit to the scatter chart that I created, you need to access this Customize tab. Follow the steps below:
- Click on the Customize tab of the Chart Editor.
- Select the Series drop down menu.
- If you scroll down the drop down menu, you will see three checkboxes.
- Select the ‘Trend line’ checkbox.
This will display a trend line (or line of best fit) across your scatter chart.
In our example, you will notice the trend chart shows an upward trend. That means as the number of ads are increased, sales start going up.
Making Changes to the Trend Line
Now that you know how to find the lineIf you want to further customize the trend line, here’s what you need to do. Under the trend line checkbox, there are a number of options to customize the trend line. For example, you can:
- Change the type of trend line. You have the option to select linear, exponential, polynomial, logarithmic, power series, and moving average trend lines.
- Change the line color.
- Change the opacity and thickness of the trend line.
- Change the label for the trend line.
- Display the R2 value. This value helps you see how closely the trend line fits the data. The closer this value is to 1, the closer the fit.
- If you select Polynomial as your trend line type, you will also get the option to select the polynomial degrees.
- If you select Moving Average as your trend line type, you will get the option to select the type of average, i.e. Trailing or Centered. You can also select the number of periods for the Moving Average trend line.
Play around with the different options until you finally obtain a trend line that provides you with enough insight on your data.
In this tutorial, I showed you how to add a line of best fit in Google Sheets to analyze and make effective inferences about your data.
The line of best fit (or trend line) can help you observe trends and patterns in your data, can help you understand how closely your data points relate to one another and it can help you identify outliers in the data, which would have been otherwise difficult to find out.
I hope this tutorial was helpful for you.
Other Google Sheets tutorials you may like: