Using gnuplot 4.2, is it possible to obtain the value of a specific column/row and use that value somehow?
For example, let's say my datafile contains the following
#1 2
7 13
5 11
23 17
53 12
For a simple plot where column 1 is the x axis and column 2 is the y axis I would:-
plot 'datafile' using 1:2
What I'm trying to do is to normalize the all data in column 2 by the first element in that column (13). Is there a way to do this in gnuplot itself (i.e., without resorting to a scripting language or something to preprocess the data first)?
Cheers
Using the running averages demo, I managed to achieve a plot normalized to the first value of the second column.
The base
variable is used to store the reference value, and the first
function initializes base
on the first row.
first(x) = ($0 > 0 ? base : base = x)
plot file.dat u 1:(first($2), base/$2)
It should be mentioned that this was not done using gnuplot 4.2.
Edit: Updated using Christoph's advice.
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