Short answer:
This will create individual plot files for each data series vs column 1:
for i in {2..7}; do `gracebat -nosafe -hdevice PNG -printfile $i.png -block a.txt -bxy 1:$1`; done
Long answer:
If you wanted to plot all columns (from number 2 up to and including e.g. column 7) vs column 1 on the same axes you could do:
for i in {2..7}; do echo -n " -block file.dat -bxy 1:$i"; done | xargs xmgrace
But since your question is asking for individual plots we can do this:
for i in {2..7}; do echo -n " -block file.dat -bxy 1:$i" | xargs xmgrace; done
or this, which give the same result but is simpler:
for i in {2..7}; do echo -n `xmgrace -block file.dat -bxy 1:$i`; done
However, this is not very practical because the individual plots appear one by one and each has to be closed for the next one to appear.
It would be better to get xmgrace to run in batch mode and to save an image of each plot for you. You can do this with an xmgrace batch file and by using the gracebat
executable.
for i in {2..7}; do `gracebat -nosafe -batch save.bfile -block a.txt -bxy 1:$1`; done
This calls grace in batch mode with the same data as before but runs the batch commands saved in save.bfile
, which contains:
PRINT TO "out.ps"
PRINT
The obvious problem with this is that each new iteration overwrites the out.ps
postscript file because the name of the output file is hardcoded in our batch file! So you only ever see the last one in the file. Luckily we can use sed to modify the batch file each time before we call gracebat!
for i in {2..7}; do `sed -e "s/outName/${i}/g" save.bfile > new.bfile`; `gracebat -nosafe -batch new.bfile -block a.txt -bxy 1:$1`; done
Where save.bfile now contains
PRINT TO "outName.ps"
PRINT
and the string outName
gets replaced by $i.
You should now have a load of .ps files with your plots inside. Play around with the batch file in order to do more things with it. See this page for more commands that you can include, including how to change the output file format.
Alternatively you can skip using batch files altogether:
for i in {2..7}; do `gracebat -nosafe -hdevice PNG -printfile $i.png -block a.txt -bxy 1:$1`; done
If you have a parameter file you can add the -param command to set styles too.