How to Insert Line of Best Fit in Google Spreadsheets
Last Updated :
23 Jul, 2025
How to Find the Line of Best Fit on Google Sheets
- Select the Customize tab from the Chart Editor
- Select the Series drop-down menu
- Scroll down to the three checkboxes
- Click on the Trend Line checkbox
Creating plots is a crucial aspect of working with spreadsheet software like Google Sheets and Microsoft Excel. Frequently, we encounter scenarios where we need to analyze data obtained from experiments or external sources, and manually identifying trends can be challenging. In such cases, we employ the technique of polynomial fitting from Statistics to determine a mathematical function that optimally aligns with the provided data. The utilization of graphs and charts for data visualization remains a valuable method for extracting insights and understanding relationships among different data points.
Insert Line of Best Fit in Google SpreadsheetsWhat is a Line of Best Fit
The line of best fit represents the relationship between two variables in a scatter plot, allowing for predictions. It minimizes the distance between the actual data points and the predicted ones. The line of best fit can be straight or curved, depending on the data's spread. Tools like Google Sheets make finding the line of best fit easy.
In this article, we will learn how to find the line of best fit (Polynomial Fitting) for a given data in Google Sheets. Google Sheets provides many functions that help us to find the best-fit line and add it to the plot of given data.
How to Create Scatter Chart in Google Sheets
Before Adding a line of best fit in google sheets you need to create a scatter chart. Follow the below steps to learn how to create a Scatter chart in Google sheets
Step 1: Select Your Data
Highlight the data you want to plot, ensuring you include both the X (independent variable) and Y (dependent variable) values.
Step 2: Insert a Chart
Click on Insert in the top menu and Select Chart from the dropdown menu. Google Sheets will automatically create a chart based on your selection.
Step 3: Choose Scatter Chart
In the Chart Editor on the right, go to the Setup tab and From the Chart type dropdown menu, select Scatter chart.
Step 4: Customize Your Chart
Switch to the Customize tab in the Chart Editor to modify chart elements like titles, axis labels, and point styles.
Step 5: Add a Trendline (Optional)
If desired, you can add a trendline by selecting Series in the Customize tab and checking the Trend line option.
Step 6: Finalize and Position Your Chart
Once you're satisfied with the chart, click outside the Chart Editor to close it. You can resize or move the chart as needed within your spreadsheet.
How to Find the Line of Best Fit on Google Sheets
To determine the line of best fit in Google Sheets, you don’t need to rely on an equation. Instead, you can achieve this by making a few straightforward customizations to your scatter plot.
Step 1: Create a Scatter Plot of Some Data
Before adding a line of best fit, we need a scatter plot of the data for which we require the best-fit line. Now, for demonstration purposes, we shall use the following data.
If you want to learn How to Create a Scatter Plot of Some Data Click here
X | Y = f(X) |
---|
3 | 27.247 |
5 | 127.141 |
8 | 509.875 |
9 | 728.709 |
13 | 2196.798 |
Step 2. Open New Spreadsheet
Now open a new spreadsheet in Google Sheets and add the above data to the spreadsheet. Then, click on Insert in the toolbar and then choose Charts
New Sheet > Insert > ChartsStep 3. Open Chart Editor
Now, this will create a default line chart and open the chart editor. Here, the first option will be to select the chart type from a drop-down menu. From this menu, select the scatter chart option.
Selecting scatter Plot as the Chart type for our Chart/PlotNow, our plot will look as follows:
Scatter Chart in Google SheetsStep 4. Adding Line of Best Fit Trendline
Now, that we have our plot, we can add the line of best fit to our data. To do the same, we need to open the chart editor, which can be accessed by clicking on the three dots icon on the top right corner of the chart and then, choosing Edit the chart.
Accessing the Chart Editor in Google SheetsStep 5: Customize and Select Series
Now, in the chart editor, select Customize from the horizontal options, and under the Customize section, select Series as shown in the figure below.
Accessing the Advanced customization options for the chart to add the line of best fit to it.Step 6. Check the Trend Line
Now, under the Series section, check the trend line option to add a trend line (line of best fit) to your chart. The default nature of the trend line is linear; which is not always the best option with the majority of real-life data. Thus, for the best fit in most cases, we should keep the trend line as a polynomial. This can be done by changing the type of trend line to Polynomial, as shown in the figure below.
Option for adding the line of best fit/trend line to the chartStep 7. Preview Added Line of Best Fit
Once this is done, a line of best fit will be added to your chart. A thing to be noted is that Google sheet smartly detects the degree of polynomial of best fit however, this can be changed by the user according to their will. Now, our chart will look something like this.
Note: The blue curve represents the line of best fit for the data we used in this example.
Scatter Plot with Line(Curve) of best fit in Google SheetsHow To Find the Slope of a Line of Best Fit In Google Sheets
Now, for those who need extra insights into their data, they can get the equation of the best-fit line used and also the R^2 value of the line. The R^2 value represents how well the best-fit line fits the given data. The closer the value is to 1, the better the fit. Absolute 1 means the line fits the data. To add these values, we only need to choose the options in the chart editor.
How to Find R2 in Google Sheets [R-Squared]
Under the Trendline Checkbox, there are options for Label and a checkbox for \bold{r^2}. Set the label to Use Equation from the dropdown menu and tick the checkbox for R-squared value.
Adding the R-squared value to the chartOnce, the above steps are done, the graph should look like this:
Chart line of best fit, trend line equation, and R-square value.As we can see, the graph now displays the equation of the best-fit curve and the R-squared value.
Conclusion
In this article, we have learned the process of adding a line of best fit to a scatter plot in Google Sheets, using randomly generated data. Initially, we created a basic scatter plot using dummy data. Next, we outlined the steps to access the chart editor in Google Sheets, enabling us to incorporate the line of best fit into our scatter plot. Finally, we elucidated how to display the equation representing the line of best fit, as well as the R-squared value, directly on the chart.
Similar Reads
How to Insert Cells in Google Sheets How to Insert Cells in Google Sheets - Quick StepsOpen Google Sheets>>Choose your SpreadsheetSelect a Cell>>Perform a right-clickSelect Insert Rows or ColumnsCells InsertedIn Google Sheets, inserting cells can help you structure your data more effectively, allowing you to add new informa
7 min read
How to Insert Multiple Columns in Google Sheets Mastering Google Sheets is more than just knowing how to enter data â it's about making your spreadsheets work for you! Whether youâre managing a project, analyzing data, or collaborating with a team, knowing how to efficiently insert multiple columns in Google Sheets can save you time and keep your
9 min read
How to Make a Budget Spreadsheet in Google Sheets Creating a budget spreadsheet is an essential skill for managing personal finances, and Google Sheets offers a versatile platform to make this task easy and efficient. Whether youâre new to budgeting or looking to streamline your financial tracking, learning how to make a budget spreadsheet in Googl
6 min read
How to Insert Line Breaks in Google Sheets: Step-by-Step Guide Inserting line breaks in Google Sheets can greatly enhance your data's readability and organization, especially when working with lengthy text entries. Whether you're formatting addresses, lists, or notes, knowing how to insert a line break using shortcuts or formulas is essential. This article will
6 min read
How to Insert a Vertical Line in Google Docs Google Docs is a free online document editor provided by Google. Google Docs is used for creating, and editing documents. As a document editor, it has extensive features available free of cost such as image insertion, table insertion, and formatting text in the document by changing its font size, fo
8 min read
How to Fit Long Text in Excel Spreadsheets? By default, when you create a new workbook in Excel, the row height and column width for all cells are set to the same value. If the text you enter in a spreadsheet cell is too long and the next column has data, it either spills over into the next blank cell or is truncated by the data in the adjace
4 min read