Search code examples
xmgrace

Xmgrace: plot all columns in multiple column file as a function of the first


I know that with xmgrace if I have a multiple column file I can plot a certain column as a function of another (say, 3 vs 1) with the command

xmgrace -block file.dat -bxy 1:3

If I want to plot 2vs1 and 3vs1 in the same window, I will simply use the command

xmgrace -block file.dat -bxy 1:2 -block file.dat -bxy 1:3

But if the files contains a large number of columns and I want to plot all of them as a function of the first (2vs1, 3vs1, 4vs1 etc.) in the same window it becomes impractical to use this command.

Is there a simple command to plot all the columns in a file as a function of the first (2vs1, 3vs1 etc.)?

I have tried

for i in {2..n}; do xmgrace -block file.dat -bxy 1:$i; done

But this way the plots will appear in different windows...


Solution

  • The nxy option is designed to do this.

    xmgrace -nxy file.dat
    

    With this option, xmgrace reads the first column of file.dat as x-data and every other column as y(i)-data, and plots y(i) vs x on the same graph (using different colors by default).