I have two files A and B. Both files contain 2 columns, x and y.
Now, I want to plot a graph for x vs (yA - yB). Does gnuplot provide a command for the same ?
One more thing, lets say xA and xB are not same. How should I plot a graph where x-axis contains all elements which are in both, xA and xB and y-axis is the difference is the corresponding y-components ?
First, preprocess the files with join in bash:
join <(sort -k1,1 file1) <(sort -k1,1 file2) > file3
Sorting the files is essential, otherwise join would not work.
Then you can use the result to draw the graph:
plot '< sort -n file3' using 1:($2-$3) with lines
Again, numeric sorting is needed here, because join uses alphanumeric sorting which makes the lines cross each other.
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