I've got two datasets referring to the same process executed in two different ways. The execution A
is slower than the execution B
with respect to real time, but the two graphs represent the same phenomena..
I can plot the two together as follows:
plot 'A' using 1:2, 'B' using 1:2
But I obtain two graphs with different X scales: A
was slower, so the graph is much.
I can normalize the graph by doing the following:
plot 'A' using ($1 / maxA):2, 'B' using ($1 / maxB):2
Which works perfectly for me. The only problem being the maxA
and maxB
variables. They are trivial to determine (tail -n1 A | cut -f1
and tail -n1 B | cut -f1
respectively), but I was wondering if there's an automated way of doing it.
Thanks in advance for any kind answer.
Update
After I applied the excellent answer from Wrzlprmft, I finally got to the following pattern, which is quite convenient:
max(Source) = system('tail -n ' . Source . '| cut -f1')
A = 'path/to/A'
maxA = max(A)
plot A using ($1 / maxA):2
Another possible improvement could be including a Column
parameter to the max
function, so that we can also tune the param of the -f
flag in cut
.
Update
Changed my mind on acceptance, since the stats
command seems to be better for this purpose.
Thanks everyone.
Alternative is to use the
stats
command in gnuplot, without any external programs:It also produces a lot more useful statistics of your data, check the variables it produces with
show var A
(orB
, orSTATS
if you didn't supply a name).OR (different solution), you plot B on the x2y1 coordinate system, where the x2 axis gets autoscaled independently.
If you know the relation between your abscissa values, you can directly link the two axes since gp 5.2