5

I have file with two columns like:

1.2, 3.4
5.6, 7.8
...

I want gnuplot to plot both columns in one coordinate system like it would, if there was only one column. Meaning: X-axis shows the line numbers, y-axis the values.

Example: The first two points of the two lines are (0, 1.2)and (0, 3.4); the second points (1, 5.6) and (1, 7.8).

I do not want the two columns being treated as x and y values, like it would if just go for plot "data.txt".

1 Answer 1

6

You can use the zero pseudo column which holds the current sample number. From help pseudocolumns:

column(0)
    The sequential order of each point within a data set.
    The counter starts at 0 and is reset by two sequential blank

For example:

plot 'data.txt' using 0:1, '' using 0:2

The empty '' uses the same data-source as the previous plot.

Sign up to request clarification or add additional context in comments.

2 Comments

you might want to explain the pseudo-column 0 as well. That's just as magical as the pseudo-file '' in my opinion :) -- But good answer, +1 from me
@mgilson: Good point thanks. I've added explanation and reference to the help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.