Imagine I have a data file with two column. In gnuplot
running
stats 'datafile' u 1:2
allows me find the minimum and maximum for the two columns. The variable
STATS_index_min_x
and STATS_index_min_y
give respectively the index of the
minimum for the first and second column. It says in the documentation that they
are such that
data[STATS_index_min_x] == STATS_min_x
Now imagine that need to have access to data[STATS_index_min_x-1]
or
data[STATS_index_min_x+1]
. How can I do that ? Actually how can I access any
particular data of any column in gnuplot
?
As far as I know, you cannot access the data in your file in this way (i.e. like an array).
On Linux/cygwin, you could work with an helper function that extracts the value directly from the underlying datafile using awk
. You can define the following function:
getValue(row,col,filename) = system('awk ''{if (NR == '.row.') print $'.col.'}'' '.filename.'')
If your datafile is called datafile
and contains these values:
1 1.4
2 4.3
3 2.5
4 0.0
5 9.0
Which gives:
gnuplot> print getValue(3,1,"datafile")
3
gnuplot> print getValue(1,2,"datafile")
1.4
Gnuplot
hadn't been designed for this, but you can cheat a little bit ;-)
stats 'datafile' u 1:2
plot[STATS_index_max_x+1:STATS_index_max_x+1.5] 'datafile.dat' u 0:1
then GPVAL_DATA_Y_MIN
(and GPVAL_DATA_Y_MAX
) contains the value you wanted.
NOTE
plot '<datafile>' u 0:<column>
plots the desidered column versus 0,1,2...
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