12

I have a two-column file which has 1000000 entries, that is 1000000 rows, however I don't want to plot all the data, I just want to plot the points every 100 lines? How to do this in gnuplot? Also, is it possible to specify some particular rows to plot in gnuplot?

1
  • You can make use of awk in gnuplot. Happy to explain, if you explain your problem in more detail. Commented Jan 27, 2013 at 2:26

1 Answer 1

28

You have at least two options here. First, check out the documentation for help datafile every

plot 'datafile' every 100 using 1:2 

Another option is to use the pseudo-column 0 (help datafile using pseudo) in conjunction with the ternary operator (help ternary) and the knowledge that gnuplot silently ignores undefined numbers to filter the lines:

plot 'datafile' u ( ((int($0)%100)==0)? $1 : 1/0 ):2

You can make this a little more easy to understand if you use a macro:

set macro
line_number='int($0)'
plot 'datafile' u ( ( ( @line_number % 100 ) == 0 ) ? $1 : 1/0 ) : 2

Note that I only include the second because you could (in principle) use this to select very strange line numbers from the datafile (e.g. 1,100,1000,10000) which you can't do using every -- e.g.

plot 'datafile' u ( ((@line_number == 1 || @line_number == 100 || @line_number == 1000 ) $1:1/0)):2

Also see the answers to this question

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

Comments

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.