Search code examples
xmgrace

How to plot a simple graph using batch script in xmgrace


I'm new to this topic and have no idea on how to write a batch script and plot the graph in xmgrace. Also, I have not found good examples which will guide me as a beginner to write such scripts.

What I have: A simple data file.

$ cat test_manual.dat
0 0
1 1
2 2
3 3
4 4
5 5
$

My Script:

$ cat first_file.bfile
arrange(6, 2, 0.1, 0.15, 0.2)
READ NXY "test_manual.dat"
WORLD XMIN 0
WORLD XMAX 5
WORLD YMIN 0
WORLD YMAX 5
s0 line color 1
title "Ten"
PRINT TO "first_file.agr"
PRINT
$

Please let me know what changes are required to make this file work and also help with any tutorial which will guide me through the advanced concepts as well.


Solution

  • If you just need to automatically create an agr file your batch file is almost fine. Just use this:

    WORLD XMIN 0
    WORLD XMAX 5
    WORLD YMIN 0
    WORLD YMAX 5
    s0 line color 1
    title "Ten"
    SAVEALL "first_file.agr"
    

    Note that, in order to make it print the agr file, you need to xmgrace (or gracebat) with the -nosafe argument, like this:

    gracebat -nosafe -batch first_file.bfile
    

    As far as I know there are no tutorials for creating batch files for xmgrace. What I usually do is to analyse agr files produced by xmgrace and copy the parts that I want to include in the batch files. The list of commands that can be used can be found here