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 ?
I think this might be a good job for
paste
.For the file where xA != xB, I'm a little unclear whether you want to plot only the set of points with are common to both (the intersection of the two sets) or whether you want to plot all the points (the union of the sets). The union is easy:
The intersection is hard using only unix commandline tools (especially if you want to preserve the order of your input)
using Python though, it's not too bad...
and then from gnuplot:
First, preprocess the files with
join
in bash:Sorting the files is essential, otherwise
join
would not work.Then you can use the result to draw the graph:
Again, numeric sorting is needed here, because
join
uses alphanumeric sorting which makes the lines cross each other.