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?
For best results, however, you should run gnuplot from within X Window, so that you can see better previews of your plots. Entering Data All the data sets you use in gnuplot should be typed into a text file first. There should be one data point per line.
Producing Printed Output gnuplot is very device-neutral: when producing your plots, it could care less whether it is producing a preview on an X Window display, an ASCII-art version for a terminal, or any other output form. The plot commands will all work the same.
All the data sets you use in gnuplot should be typed into a text file first. There should be one data point per line. Each data point will consist of several numbers: the independent variable, the dependent variable, and optionally error bars. Each of these fields should be separated by a tab.
The set y2tics bordercommand tells gnuplot to display this scale on the border of the plot. Without it, the new scale would be set, but it would not be shown on the right-hand side of the plot. Now it's time to add our residuals. We add them to the plot command, and specify that they should use the new y scale.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With