Smoothing draws a gentle curve through noisy measurements so the underlying trend is visible, while the raw points stay on the same figure to keep the smoothing honest.
$DATA << EOD
0 1.0
1 2.2
2 1.8
3 3.1
4 2.7
5 4.0
6 3.6
7 4.8
8 4.4
9 5.5
10 5.2
EOD
set title "Raw Points with Smoothed Curves"
set xlabel "x"
set ylabel "y"
set grid
plot $DATA using 1:2 with points pointtype 7 pointsize 1.2 title "Raw data", \
$DATA using 1:2 smooth csplines with lines linewidth 2 title "smooth csplines", \
$DATA using 1:2 smooth bezier with lines linewidth 2 dashtype 2 title "smooth bezier"
How the script works
The same datablock is plotted three times. The first element draws the raw measurements as points — always include them, because a smoothed curve on its own can hide gaps and outliers in the data.
smooth csplines fits a natural cubic spline through the points: the resulting curve passes through every data point but replaces the straight segments with smooth bends, which suits data you believe is continuous underneath the noise. The keyword goes between the using spec and the with style.
smooth bezier takes the other approach: it draws a Bezier curve that follows the trend of the points without necessarily passing through them, which reads better for genuinely noisy data where individual points should not be trusted exactly. Plotting both, as here, is the fastest way to choose between them for a given dataset.
Run it online: Paste this script into the online terminal and run it — no install needed.
Variant to try
For repeated measurements at the same x values (several y readings per x), use smooth unique first in the chain or on its own: it averages the y values per x before the chosen smoothing sees them. On large noisy files, smooth sbezier (the Bezier variant that first averages) is often the most stable choice. Note that smoothing changes the picture, not the data — for numbers you can defend, fit a model instead.
Related tutorials: Curve Fitting with fit, Plot CSV Data in Gnuplot. See more copy-and-run scripts in the Gnuplot Examples index.
Scripts on this page are adapted from the official gnuplot 6.0 demo collection (gnuplot.info) and rewritten for this tutorial.
