Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .