Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotting data from two files after performing mathematical operation between them

Tags:

plot

gnuplot

I have

FileSFC1: contains certain data
FileSFC2: contains some other data

Now what I need to do is divide the second column of FileSFC1 with the second column of FileSFC2 and then plot this result. So something of the form:

plot ( FileSFC1 using 1:1 / FileSFC2 using 1:1 ) * 100

So basically the plot would be a percentage of the columns in the two files. Please help.

like image 434
Bilal Hameed Avatar asked Mar 07 '13 05:03

Bilal Hameed


1 Answers

Gnuplot can only manipulate columns of data that are from the same 'file' or data stream. What you can do is use the plot '< bash command' construction. When the argument to plot starts with < what happens is the rest of the argument is interpreted as a bash command, and the output of that command is what is plotted. So:

plot '< paste FileSFC1 FileSFC2' u (100*$2/$4)

This assumes that both files have two columns, and you want to plot the percentage of the 2nd column in each file. To perform manipulations on data columns, the syntax is to enclose the argument to using in parentheses and prefix column numbers with a dollar sign.

like image 101
andyras Avatar answered Oct 23 '22 12:10

andyras