Karl Ratzsch - 2026-08-06

The first datapoint should just be kept as-is, because there is no knowing in advance what the data range actually is, e.g. +-pi or 0 to 2pi. And if somebody has data that goes from 5pi to 7pi, they probably have some extra knowledge the plot should preserve. ;)

Attached the two-liner fix.

I was slightly confused about the while loop below the change, I think it can be removed and always run exactly once. If there is a jump larger than 3pi in some data, then smooth unwrap is obviously not the right treatment.

Test:

set xr [0:10]
set samp 400
mod(a,b) = a - b * floor(a / b)
testf(x) = mod(1.9*pi*cos(x),2*pi)-pi
plot testf(x),  '+' us 1:(testf(x)) smooth unwrap

The test shows another bug: if no yrange is set, the unwrapped plot leaks out of the graph borders.