Show Sidebar Hide Sidebar

# Fitting data with a quadratic function

Plotly offers free, online tools for analyzing data and making graphs. In this tutorial we’ll show you how to fit quadratic curves to your data and explain what that means. Make sure to check out our other tutorials to learn how to fit your data with other polynomials, gaussians, exponentials, and logarithms.

 A quadratic function is a second degree polynomial. That means it can be written in the form \$f(x)=ax^2+bx+c\$, where the coefficient \$a\$ isn’t zero. The picture on the right shows two quadratic functions. Curves with this shape are called parabolas. All quadratic functions look like the examples in the picture. A parabola opens upward if \$a\$ is positive and it opens downward if \$a\$ is negative. Quadratic functions grow (or decay) faster than linear functions for large enough \$x\$ values. The growth rate of a variable with respect to another variable is an important factor to consider when choosing a function to fit to your data. If \$f(x) = ax^2+bx+c\$, then \$f\$ is a quadratic function and its growth rate (or rate of change) is linear. If your data looks like a parabola or you calculate that the rate of change is almost linear, you will want a model with a quadratic function. Modeling data with a quadratic means picking the coefficients \$a\$, \$b\$, and \$c\$ to make the parabola look like the graph of the data set. Plotly finds these coefficients and calculates the \$R^2\$ value, also called the coefficient of determination. This value indicates how well the quadratic function fits your data set. The closer the \$R^2\$ value is to 1, the better the fit.

### Step 1: Make a plot

We have lots of great tutorials to help you make line graphs, scatter plots, histograms, bar charts, and more. If you need help, you’ll find everything you need on our tutorials page.

 You can import files from Google Drive, Dropbox, or Excel for your graphs. You’ll find more details in our “How to make a plot from the grid” tutorial.For this tutorial we’ll use a data set that you can find at: https://plot.ly/~mariahh/51 To make a scatter plot, choose Scatter plots from the MAKE A PLOT menu.Plotly will automatically select the first column of data to be x values, and the second column to be y values. In our case, this is exactly what we want.Click on the blue Scatter plot box in the sidebar to make your scatter plot. Your plot will open in a new tab.