3

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.

2
  • 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 Aug 21, 2013 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, 2013 at 7:37

1 Answer 1

2

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.

You must log in to answer this question.

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