how-to · 5 min read
Polynomial fits and multi-series plots
A polynomial fit can follow curvature that a straight line misses, but every extra degree also buys flexibility to follow noise. The same trade-off appears when several data series share one chart: overlaying series makes comparisons convenient, while making it easier to compare the wrong things.
This guide covers the least-squares polynomial fits in the experimental data plotter, how to choose a degree, how to recognise overfitting and unreliable extrapolation, and how multi-series charts and per-series fits should be read and reported.
What a polynomial fit actually minimises
A least-squares polynomial chooses coefficients that minimise the sum of squared vertical distances between the data points and the curve. Degree 1 is the familiar straight line, degree 2 adds an x² term and can bend once, degree 3 adds x³ and can bend twice, and degree 4 adds x⁴. The plotter reports the coefficients, r² and the number of points, so the curve can be checked rather than trusted.
Adding a term can never increase the sum of squared errors, so r² rises with degree almost automatically. That is why r² alone cannot choose a model: a degree-4 fit will beat a straight line on r² even when the extra terms are only following noise.
Choosing a degree without fooling yourself
Start from the physics, chemistry or instrument response: an exponential-like curve over a narrow range may look quadratic, a calibrated detector may have a quadratic response, and a straight line is often the correct model for a calibration. Plot the points before fitting, then compare adjacent degrees and keep the lowest one that captures a real pattern rather than small wiggles.
A small worked example shows the arithmetic. Four points at (−1, 6), (0, 1), (1, 2) and (2, 9) are fitted by the quadratic y = 3x² − 2x + 1, which passes through all four with r² = 1. Three points would determine the same parabola uniquely, so the fourth point is genuine support for the shape rather than a constraint; with only three points, r² = 1 would prove nothing.
A fit with as many points as coefficients passes through every point and reports r² = 1 by construction; that is arithmetic, not evidence. State the degree, the number of points and the x range with the equation, because a fit is only meaningful inside the range that was measured.
Overfitting and extrapolation
High-degree polynomials are flexible enough to bend between points, so they can fit noise beautifully and still predict badly. A useful check is to remove one point, refit and see whether the curve changes shape near that point: a stable fit changes little, while an overfitted curve can swing wildly.
Polynomials also behave badly outside the data range, where the highest term grows fastest. Extrapolating a fitted parabola past the measured x values is not an estimate of the real trend, and extrapolating a quartic is almost always indefensible.
Putting several series on one chart
The plotter's multiple-series mode takes one point per line as series, x, y or series, x, y, error; rows with the same series name are grouped, and series names may repeat across rows. Each series is drawn with its own marker and line style, the legend names them, and the CSV keeps the series column so the grouped data can be checked afterwards.
Overlay series only when they share units and comparable conditions, and avoid so many series that the markers blend together. When one series has a much larger scale, separate charts are clearer than shared axes that compress the small series; when fits are enabled, the fit results table lists each series separately.
Reporting polynomial and multi-series results
For every fitted series report the degree, the equation, r² and n, and say why that degree was chosen. Do not quote r² from a fit through n = degree + 1 points as if it measured quality, and do not compare r² across data sets with different ranges as if it ranked their models.
In the figure caption, state which markers and lines belong to which series, what the error bars represent, and whether a curve is a fit or a guide to the eye. That information is what lets a reader judge the claim instead of just looking at a tidy chart.
- Fit the lowest degree that follows a justified pattern.
- Report degree, equation, r², n and the measured x range.
- Treat r² = 1 with n = degree + 1 as arithmetic, not evidence.
- Do not extrapolate a polynomial past the measured range.
- Keep series on one chart only when units and conditions are comparable.