Plotting Graphs, Line of Best Fit, and Gradients

Plotting a graph shows the relationship between two quantities: the points are plotted with the independent variable on the x-axis, a line of best fit is drawn through the trend, and the gradient (rise ÷ run) of the line gives a physical quantity, while the intercept shows any offset. In brief: choose axes and a scale that use more than half of the grid, label them with quantity and unit, plot points accurately, add error bars if uncertainties are known, draw a smooth straight line with points scattered evenly above and below, and find the gradient using a large triangle on the line itself, not using data points. The uncertainty of the gradient comes from the steepest and shallowest acceptable lines.

Graphs average out random errors across all the points and make anomalies and systematic errors visible, so they are a central tool of physics. This guide explains how to plot and label a graph, how to draw the line of best fit, how to calculate the gradient and the intercept and their uncertainties, compares graph features in a table, works through the pendulum data and corrects common mistakes.

How do you plot a graph?

How do you draw a line of best fit?

The line of best fit shows the trend of the points. Draw it with a transparent ruler (to see all the points) for a straight line, or as a smooth curve (not “joining the dots”) if the data show a curve. Rules: there should be about the same number of points above and below the line, spread along its length; the line does not have to pass through any point, nor through the origin unless the physics requires it; any anomalous point (far from the trend) is circled and ignored in drawing the line, but not hidden. A statistical least-squares fit (spreadsheet or calculator) minimizes the sum of the squares of the vertical distances to the line and gives the best gradient m and intercept c; the formulas are m = (nΣxy − ΣxΣy) ÷ (nΣx2 − (Σx)2) and c = (Σy − mΣx) ÷ n. The correlation coefficient r (close to ±1 for a good linear relation) shows how well the line fits, but a high r does not prove that the relationship is correct.

How do you find the gradient and intercept?

The gradient is Δy ÷ Δx, found from two points on the line (not data points, unless they lie on it), as far apart as possible, using at least half of the line’s length. Show the triangle on the graph and read the coordinates carefully. The gradient has units (the units of y divided by those of x) and a physical meaning: for T2 against L, it is 4π2/g in s2/m. The y-intercept is the value of y at x = 0 (read directly if the x-axis starts at zero, otherwise calculated from y = mx + c with a point on the line). To find the uncertainty in the gradient, draw the steepest and the shallowest lines that are still consistent with the data (through the error bars, passing through the center point of the data), and calculate their gradients: the uncertainty is half the difference, (mmax − mmin) ÷ 2. The same method gives the uncertainty in the intercept. The area under a graph is also useful: the area under a velocity–time graph is displacement, and the area under a force–extension graph is work done.

Pendulum graph of T squared against L with line of best fit and gradient triangle 0 0.2 0.4 0.6 0.8 1 0 1 2 3 4 L (m) T² (s²) ΔL = 0.8 m ΔT2 = 3.2 s2 gradient = 4.03 s²/m
The pendulum data from the worked example. The solid line is the least-squares line of best fit (gradient 4.03 s²/m, intercept close to zero). The dashed triangle shows how the gradient is found from points far apart on the line, and the two dotted lines are the steepest (4.10) and shallowest (3.95) acceptable lines used to estimate the uncertainty.

Graph features compared

What features of a straight-line graph tell you
Feature How it is found What it shows Example
GradientΔy ÷ Δx on the linePhysical constant or rateV against I: resistance R
y-interceptValue of y at x = 0Offset, systematic error or fixed termV against I for a cell: emf (with a negative gradient −r)
Line through the originIntercept equal to zero within uncertaintyDirect proportionalityT² against L
Scatter about the lineDistance of the points from the lineRandom errorsWide scatter means imprecise data
Area under the graphCount squares or integrateProduct of the two quantitiesArea under v–t: displacement

Worked example: g from the pendulum graph

The pendulum data (L in m, T2 in s2) are: (0.200, 0.810), (0.400, 1.613), (0.600, 2.434), (0.800, 3.204), (1.000, 4.040).

  1. Axes: L on the x-axis from 0 to 1.0 m (2 large squares per 0.2 m); T2 on the y-axis from 0 to 4.5 s2. The points lie close to a straight line through the origin.
  2. Least-squares sums: Σx = 3.000, Σy = 12.101, Σxy = 8.8708, Σx2 = 2.200 (n = 5).
  3. Gradient: m = (5 × 8.8708 − 3.000 × 12.101) ÷ (5 × 2.200 − 3.0002) = (44.354 − 36.303) ÷ (11.000 − 9.000) = 8.051 ÷ 2.000 = 4.03 s2/m.
  4. Intercept: c = (12.101 − 4.0255 × 3.000) ÷ 5 = 0.005 s2, which is zero within the uncertainty, as expected for T2 proportional to L.
  5. Graphical check: using the two end points of the line as a large triangle, (4.040 − 0.810) ÷ (1.000 − 0.200) = 4.04 s2/m, close to the least-squares value.
  6. Value of g: the gradient is 4π2/g, so g = 4π2 ÷ 4.0255 = 9.81 m/s2.
  7. Uncertainty (illustrative): suppose the steepest acceptable line has gradient 4.10 and the shallowest 3.95 s2/m. The uncertainty is (4.10 − 3.95) ÷ 2 = 0.075, which is 1.9 percent of the gradient. The percentage uncertainty of g is the same, so Δg = 9.81 × 0.019 = 0.19 m/s2: g = 9.8 ± 0.2 m/s2, consistent with the accepted value of 9.81 m/s2.

How did graphs develop?

Nicole Oresme drew early graphical representations of changing quantities in the 14th century. René Descartes’ coordinate geometry (1637) gave the mathematical foundation for plotting. William Playfair introduced the line and bar charts for data in the late 1700s, and graph paper became widespread in science and education in the 19th century. Today, spreadsheets and software perform least-squares fits and plot error bars, but the interpretation is still the task of the scientist.

Which mistakes are common?

Mistake 1: Joining the dots instead of drawing a best-fit line

The line should show the trend, not pass through every point, as random errors move individual points.

Mistake 2: Taking the gradient from data points far from the line, or from a small triangle

Use two well-separated points on the line itself, and show the triangle.

Mistake 3: Forgetting the units of the gradient

The gradient has the units of y divided by the units of x, and these show what it means.

Mistake 4: Forcing the line through the origin

Draw the best-fit line from the data; an intercept that is not zero shows a systematic error or a real offset.