Search code examples
batch-processingxmgrace

How to set a property for all sets in xmgrace in a single statement


Suppose I have file1.dat and file2.dat. I want to plot them and, for both sets, set the line-width of to 2 (for error-bars too) and the symbol to a circle. Currently, I invoke

xmgrace -batch batch.xmg

with this batch.xmg:

READ XYDY "file1.dat"
READ XYDY "file2.dat"

S0 LINEWIDTH 2
S0 SYMBOL 1
S0 ERRORBAR LINEWIDTH 2
S0 ERRORBAR RISER LINEWIDTH 2

S1 LINEWIDTH 2
S1 SYMBOL 1
S1 ERRORBAR LINEWIDTH 2
S1 ERRORBAR RISER LINEWIDTH 2

It works as expected, however batch.xmg becomes big and very repetitive as the number of data files (and, consequently, sets) increases. Besides, whenever I want to modify a common property, I have to go through all sets and change the corresponding value (or to employ a text-processing tool such as sed).

Then, I ask: Is there any way to make a global statement that sets a property for all sets? For example, something like

SETS SYMBOL 1

I thought that statement would work according to this manual, but it does not. Xmgrace raises an error and draws no symbol for all sets.


Solution

  • I had overlooked the Defaults section. These statements are available:

    DEFAULT LINESTYLE number
    DEFAULT LINEWIDTH number
    DEFAULT COLOR number
    DEFAULT CHAR SIZE number
    DEFAULT FONT number
    DEFAULT SYMBOL SIZE number
    DEFAULT SFORMAT number 
    

    I found out that you need to write them before the read statements if you want the defaults to apply to them. For example, this will set the line-width and line-style for file2.dat, but not for file1.dat:

    READ XYDY "file1.dat"
    
    DEFAULT LINEWIDTH 3
    DEFAULT LINESTYLE 3
    
    READ XYDY "file2.dat"
    

    However, notice that, unfortunately, not all properties are available (for instance, you can't set DEFAULT SYMBOL 1).