Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a data series that I'm trying to plot in Gnuplot of the format:

x1, y1, x2, y2 ... xn, yn

Where every two adjacent columns represent an xy pair. I'm looking for a way to plot each of these xy pairs as separate lines using a single (concise-ish) command in Gnuplot, rather than trying a command like this:

plot "file" u 1:2 w l, "file" u 3:4 w l

...and so on.

share|improve this question
Seems like something from Dr.Kawano's gnuplot FAQ, but the original link is down, so either use Wayback Machine or this mirror. Check in the 2d plot. Otherwise, try the 2D gnuplot demos – Doktoro Reichard Aug 21 '13 at 5:34
I do not understand the question. You want Gnuplot to plot lines based on coordinate pairs, right, but where should the line start from? Could you provide a more concrete example? – Thor Aug 21 '13 at 7:37

1 Answer 1

up vote 1 down vote accepted

You can use a for loop in (relatively recent) gnuplot:

plot for [i=1:4] "file" u (column(2*i-1)):(column(2*i)) w lp

will plot four curves, each based on one of the first four pairs of each line in the file.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.