I'm trying to use gnuplot to compare several data files. I get those files through a list, using an ls
command, and then I plot those files.
List = "`echo $(ls GRID/3D/Ratio_5/DATA.dat.* | sort -V )`"
This gives me a list of files DATA.dat.0001 DATA.dat.0002 ... DATA.dat.0100
representing different times, and then I can plot them using
plot for [i in List] i u 1:2 title system('basename '.i)
In that case, no issues. However, in some cases, I need to compare different Ratio_
directories (no time dependence here), so I create my list
List = "`echo $(ls GRID/3D/Ratio_*/DATA.dat | sort -V )`"
But the same plot command gives all my series the same name: DATA.dat
. I tried
plot for [i in List] i u 1:2 title system('dirname '.i)
but it prints the whole path except DATA.dat
, and I'm just interested on the Ratio_
number.
I create a function to extract the Ratio from the filename string
Ratio(filename) = "awk -F / '{print $3}' ".filename
plot for [i in List] i u 1:2 title Ratio(i)
but it just print the whole thing awk -F / '{print $3}' GRID/3D/Ratio_1/DATA.dat
for every data series. I tried to add a system
call within the definition of Ratio(filename)
without success
Ratio(filename)=system("awk '{print $3}' " .filename)
plot for [i in List] i u 1:2 title Ratio(i)
but now each data series is named like the whole 3rd column of the corresponding DATA.dat, with its several hundred lines.
I'm out of ideas. This is probably just a simple syntax problem, a misplaced quote, point or comma. I know I can call my gnuplot script in the 3D
directory and use dirname
option, but that's not what I want. I'm calling this script along with many others placed in the same directory, to create plots for a scientific article, and placing those scripts in different places would be a mess.
Any help is appreciated. Thanks