anubhav
anubhav

Reputation: 643

How to add offset to data from file while plotting in gnuplot

I want to add an offset to the data from a file which i want to plot using gnuplot. Suppose i want to add an offset of 0.001 to all the data values from file before i plot them . How can i do it in gnuplot without having to rewrite the data file with the offsets.

Thanks.

Upvotes: 14

Views: 25666

Answers (2)

Ivan
Ivan

Reputation: 31

I think it is better to let gnuplot compute offset, instead of guessing the right constant...

off(x) = sin(x) + offset
fit off(x) "data" using 1:2 via offset
plot off(x)

Upvotes: 3

Woltan
Woltan

Reputation: 14023

Try something like this:

plot "Data.dat" u ($1):($2 + 0.001) w l

The $1 and $2 specify the column you want to plot. Simply add a constant like 0.001 to the column or even add two columns like so: $1 + $2.

I hope that answers your quastion
Cherio Woltan

Upvotes: 21

Related Questions