Line of Best Fit with Error Bars & Gradient Uncertainty
Plot lab data with error bars, fit a straight line, and report the gradient uncertainty using exam max–min or statistical least-squares. Free — everything stays in your browser.
Active: Exam (UK A-level / IB). Exam: add absolute uncertainties for sums/differences; add % uncertainties for products/quotients/powers; max–min for gradients; uncertainty to 1 s.f.
Example datasets
Paste spreadsheet data (tab or comma separated) into the first empty cell area below, or edit cells directly.
| # | x | y | ±x | ±y | Remove |
|---|---|---|---|---|---|
| 1 | |||||
| 2 | |||||
| 3 | |||||
| 4 | |||||
| 5 | |||||
| 6 |
How it works
Enter x and y values from your table. Optional ± columns are error bars (or boxes if you give ±x). Choose Exam for mark-scheme style max–min gradients, or Statistical for weighted least squares with standard errors, R² and χ².
The best-fit line is ordinary least squares (or weighted when y uncertainties are present). In Exam mode, candidate lines through pairs of error-bar corners are tested; those that still intersect every bar define m_max and m_min. Gradient uncertainty is (m_max − m_min)/2.
Worked example
Exact line y = 2x + 1 for x = 1…5 (each with ±0.05 on y): load the worked example in the tool. Best-fit m = 2.00 and c = 1.00. Separately, if m_max = 1.24 and m_min = 0.90, then δm = 0.17 — about 16% of a 1.06 gradient.
Common mistakes
- Drawing max/min lines that miss an error bar.
- Quoting percentage uncertainty of the gradient as if it were percent error.
- Forcing through the origin when the intercept is physically meaningful.
- Ignoring x uncertainties when both axes have comparable relative errors.
Frequently asked questions
Q1How do you find the uncertainty in a gradient?
In exam-style work, draw the steepest and shallowest straight lines that still pass through every error bar, then take half the difference of those gradients. In statistical mode, use the slope standard error from the least-squares covariance matrix.
Q2What is the max–min gradient method?
It is the school-lab method of estimating gradient uncertainty from error bars: the maximum and minimum gradients of lines that still intersect every bar (or error box if x uncertainties are shown). Uncertainty is (m_max − m_min)/2.
Q3Should I force the line through the origin?
Only when theory requires zero intercept (for example Ohm’s law with V = IR and negligible offset). Forcing through the origin changes both the best-fit slope and its uncertainty.
Q4What if no line passes through every error bar?
That usually means the bars are too small or the data are not linear. This tool reports that clearly and falls back to statistical standard errors so you can still quote a gradient.
Q5When should I use weighted least squares?
When each y-value has its own uncertainty. Points with smaller σ_y pull the fit more strongly (weight 1/σ_y²). If x uncertainties matter too, the tool uses an effective-variance approximation.
Q6What does reduced chi-square tell me?
Values near 1 suggest the scatter matches the stated uncertainties. Much larger than 1 can mean underestimated errors or a poor linear model; much smaller than 1 can mean overestimated uncertainties.
Q7How many data points do I need?
At least two for a line, but three or more are recommended. School practicals usually use five or more points across the available range.
Q8Can I export the chart for a lab report?
Yes. Export SVG for sharp embedding in documents, or PNG for slides. Axis labels and a text legend are included so the chart does not rely on colour alone.
Q9Is this calculator free?
Yes. ΔPropagator tools are free, with no signup, no ads, and no server-side storage of your data — calculations run in your browser.
Q10Does this replace my exam board’s method?
No. Exam boards publish their own mark schemes. Use the Exam convention for typical A-level/IB max–min working, and check your specification for how they want uncertainty reported.