how-to · 5 min read
How to plot experimental data with error bars
Plotting experimental data is not decoration: the figure decides what a reader notices, so the chart type, the error bars and the axis labels all carry scientific claims. A scatter plot with labelled uncertainty is usually a fairer summary than a bar chart that hides the spread.
This walkthrough follows the experimental data plotter from pasted rows to exported figure: x,y rows with an optional error column, a scatter or line chart, axis labels, a least-squares fit with slope, intercept and r², and SVG, PNG or CSV output.
Start with tidy rows, not a formatted table
The plotter wants one measurement per row: x first, y second, and optionally the uncertainty on y as a third column. A header such as x, y, error is skipped if present, and the delimiter is detected from the first line, so a comma-separated export, a tab-separated copy from a spreadsheet and plain space-separated values all work. Keep both columns in the units of the measurement and convert before pasting if the units differ.
A short example makes the arithmetic visible. With the rows (1, 2.5), (2, 4.9) and (3, 7.2) the fitted line is y = 2.35x + 0.1667 and r² is about 0.9998, close to a straight line but not perfect. Those numbers come from the tool; your own data will give its own slope and intercept, and the point of the example is that the fit reports the relationship instead of hiding it.
Choose the chart type the data supports
Scatter is the default for independent measurements. Each point stands alone, the eye can see clusters, gaps and outliers, and nothing implies an ordering that the experiment did not have. Use line when the x values form a sequence such as time, wavelength or a temperature ramp, because connecting the points then expresses how the quantity changed between observations rather than inventing a category order.
Scatter + line shows both the individual points and the path through them, which is useful when the measurements are ordered but the spread still matters. Avoid connecting unrelated conditions such as different samples or treatments; a line through them suggests a trend that no single experiment measured.
When several conditions share the same axes, switch the plotter to multiple series and use one row per point as series, x, y (or series, x, y, error). Series names may repeat, each series gets its own marker, line style and legend entry, and the CSV export keeps the series column; keep a separate chart when the scales or units differ.
Error bars need a definition, not just a size
Add the third column when each point has a known uncertainty, such as the standard deviation of repeated measurements, the standard error of the mean, a confidence interval half-width or an instrument tolerance. The plotter draws a symmetric y error bar of that size, so whatever you place in the column must match how the figure caption describes it; an unlabelled bar is not information.
If the data has no replicate or calibration uncertainty, leaving the third column out is more honest than inventing a plausible bar. By default the error column sizes the bars only; the unweighted fit still treats every point equally.
When the errors differ a lot, an unweighted fit treats a precise point the same as a noisy one. The plotter can weight the fit by 1/σ²: rows with a positive y error carry inverse-variance weights, rows without one are left out, and the fit summary states how many points were used and whether the fit was weighted. Weight only when the uncertainties are known and independent; if they are rough guesses, the unweighted fit is the more honest default.
Add a least-squares fit only when a line is plausible
The fit answers one question: what straight line minimises the squared vertical distances to these points? It reports the slope, intercept and r², and those numbers are only meaningful when a straight-line relationship is a reasonable model over the plotted range. A curve, a cluster of categories or a single extreme value can all make the fit tidy and wrong.
Two points always produce a perfect line and an r² of 1, so a fit through two pairs is arithmetic rather than evidence. The intercept may also be meaningless if x never approaches zero. Read the points around the line, quote the equation with the range of x and the number of points, and treat a fitted line as a summary of the data rather than a law.
When a straight line is clearly wrong but the trend is smooth, the same panel offers polynomial fits of degree 1–4. A quadratic can be justified by a curved instrument response, while a quartic through a handful of points is usually following noise, so compare degrees and keep the fitted equation inside the measured range. The guide on polynomial and multi-series fitting covers the judgement calls in more detail.
Label, export and check the figure before sharing
Give the chart a title that says what is plotted, and label both axes with the quantity and its unit. The plotter lets you edit all three labels and updates the drawing as you type. Export the vectors as SVG when the figure will be scaled or edited, a 2× PNG when it goes into slides or a document, and the CSV when someone needs the cleaned numeric rows; all three downloads are generated locally.
Before sharing, check that no label or error bar is clipped. Naming the files descriptively and writing a caption that states the error-bar definition, the number of measurements and the fitted range takes a minute and prevents most figure-reading mistakes.
In multiple-series mode, each series also has its own CSV, SVG and PNG actions. The files are named after the series, with unsafe characters replaced, so one condition can be reused in a slide or report without re-plotting the whole chart.
- One row per measurement, with units converted before pasting.
- Scatter for independent points, line only for ordered sequences.
- A third column is an uncertainty: say which one in the caption.
- Only fit a line when a straight trend is plausible over the plotted range.
- Weight by 1/σ² only when the y errors are known and independent.
- Export a single series from the multi-series list when only one condition is needed.
- Export SVG for print, PNG for slides, CSV for the data.

