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?
- Axes: the independent variable (the one that you changed) goes on the x-axis, the dependent variable on the y-axis. Label each axis with the quantity and unit, such as “T2 / s2” or “L (m)”.
- Scale: choose a simple scale (1, 2, 5 or 10 units per large square, never 3 or 7) so that the points fill more than half of the width and height of the grid. Include the origin if the line is expected to pass through it or if the intercept is needed.
- Points: mark each with a small cross (×) or a dot in a circle, with a sharp pencil, within half a small square of the true position.
- Error bars: draw bars of length ± the uncertainty in y (and in x if significant) at each point. The line of best fit should pass through most of the error bars.
- Title: a short title or caption showing what is plotted.
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.
Graph features compared
| Feature | How it is found | What it shows | Example |
|---|---|---|---|
| Gradient | Δy ÷ Δx on the line | Physical constant or rate | V against I: resistance R |
| y-intercept | Value of y at x = 0 | Offset, systematic error or fixed term | V against I for a cell: emf (with a negative gradient −r) |
| Line through the origin | Intercept equal to zero within uncertainty | Direct proportionality | T² against L |
| Scatter about the line | Distance of the points from the line | Random errors | Wide scatter means imprecise data |
| Area under the graph | Count squares or integrate | Product of the two quantities | Area 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).
- 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.
- Least-squares sums: Σx = 3.000, Σy = 12.101, Σxy = 8.8708, Σx2 = 2.200 (n = 5).
- 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.
- 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.
- 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.
- Value of g: the gradient is 4π2/g, so g = 4π2 ÷ 4.0255 = 9.81 m/s2.
- 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.