7
<title>Grace User's Guide (for Grace-5.1.7)</title>
7
<title>Grace User's Guide (for Grace-5.1.18)</title>
8
8
<author>by the Grace Team</author>
9
<date>16.03.2002</date>
9
<date>28.12.2004</date>
11
11
This document explains the usage of
12
12
<bf>Grace</bf>, a WYSIWYG 2D plotting tool for numerical data.
23
23
Grace is a WYSIWYG tool to make two-dimensional plots of numerical
24
24
data. It runs under various (if not all) flavors of Unix with X11
25
25
and M*tif (LessTif or Motif). It also runs under VMS, OS/2, and
26
Windows (95/98/NT/2000). Its capabilities are roughly similar to
26
Windows (95/98/NT/2000/XP). Its capabilities are roughly similar to
27
27
GUI-based programs like Sigmaplot or Microcal Origin plus
28
28
script-based tools like Gnuplot or Genplot. Its strength lies in the
29
29
fact that it combines the convenience of a graphical user interface
55
55
Copyright (©) 1991-1995 Paul J Turner, Portland, OR
56
Copyright (©) 1996-2002 Grace Development Team
56
Copyright (©) 1996-2004 Grace Development Team
58
58
Maintained by Evgeny Stambulchik
130
130
<item> The PDF driver requires the PDFlib library of Thomas
131
131
Merz to be installed, which is available
132
132
<url name="here" url="http://www.pdflib.com/">, version
134
134
<item> If your computer has the FFTW library installed when
135
135
Grace is compiled, Grace will link itself to this, and
136
136
drop all conventional FFT's and DFT's. All transforms
294
294
from the "Plot/Graph appearance popup". You can load the settings
295
295
contained in a parameter file with File/Open.
297
<sect2>Input File formats <label id="files-formats">
297
<sect2>Input file formats <label id="files-formats">
300
Grace understands several input files formats. The most
301
basic one is ASCII text files containing space and comma
302
separated columns of data. The data fields can be either
303
numeric (Fortran 'd' and 'D' exponent markers are supported)
304
or alphanumeric (with or without quotes). Several calendar
305
date formats are recognized automatically and you can
306
specify your own reference for numeric dates formats. Grace also
307
has a command language (see <ref id="command-interpreter"
308
name="command interpreter">), you can include commands in
309
data files using lines having "@" as their first non-blank
310
character. Depending on configuration, Grace can also read
311
NetCDF files (see <ref id="configuration" name="configuration">).
300
Grace understands several input files formats. The most basic one
301
is ASCII text files containing space and comma separated columns
302
of data. The data fields can be either numeric (Fortran 'd' and
303
'D' exponent markers are also supported) or alphanumeric (with or
304
without quotes). Several calendar date formats are recognized
305
automatically and you can specify your own reference for numeric
306
date formats. Lines beginnig with "#" are ignored. Blank lines
307
indicate new dataset.
308
Grace also has a command language (see <ref
309
id="command-interpreter" name="command interpreter">), you can
310
include commands in data files using lines having "@" as their
311
first non-blank character, though this is not recommended.
312
Depending on configuration, Grace can also read NetCDF files (see
313
<ref id="configuration" name="configuration">).
313
315
<sect2>Graphs <label id="graph">
325
327
<item> Fixed Graph
331
The idea of "XY Chart" is to plot bars (or symbols in general) of
332
several sets side by side, assuming the abscissas of all the sets are
333
the same (or subsets of the longest set).
329
335
<sect2>Datasets <label id="datasets">
634
643
<tag> -rvideo </tag>
635
644
Exchange the color indices for black and white
647
Run in the safe mode (default) - no file system modifications
648
are allowd through the batch language
637
650
<tag> -saveall <it>save_file</it> </tag>
638
651
Save all graphs to save_file
692
705
<item> GRACE_HELPVIEWER
694
The HTML viewer for on-line browsing of help documents
707
The shell command to run an HTML viewer for on-line browsing of
708
the help documents. Must include at least one instance of "%s"
709
which will be replaced with the actual URL by Grace.
696
711
<item> GRACE_FFTW_WISDOM_FILE and
697
712
GRACE_FFTW_RAM_WISDOM
1199
1214
You can link a set to a file or a pipe using this feature. Once
1200
1215
a link has been established, you can update it (i.e., read data
1201
again) by clicking on the update button. If you have specified a
1202
command (using Grace language) in the corresponding text field
1203
of the popup, it will be executed after each update. Note that
1204
you can use several commands separated by ';' characters.
1216
again) by clicking on the update button.
1206
1218
Currently, only simple XY sets can be used for hotlinks.
1304
1316
<sect3> Fourier transforms <label id="fourier-transforms">
1306
This popup is devoted to direct and inverse Fourier
1307
transforms. The default is to perform a direct transform on
1308
unfiltered data and to produce a set with the index as
1309
abscissa and magnitude as ordinate. You can filter the input
1310
data window through triangular, Hanning, Welch, Hamming,
1318
This popup is devoted to direct and inverse Fourier transforms
1319
(actually, what is computed is a power spectrum). The default is to
1320
perform a direct transform on unfiltered data and to produce a set
1321
with the index as abscissa and magnitude as ordinate. You can filter
1322
the input data window through triangular, Hanning, Welch, Hamming,
1311
1323
Blackman and Parzen filters. You can load magnitude, phase or
1312
coefficients and use either index, frequency or period as
1313
abscissas. You can choose between direct and inverse Fourier
1314
transforms. If you specify real input data, X is assumed to
1315
be equally spaced and ignored; if you specify complex input
1316
data X is taken as the real part and Y as the imaginary part.
1324
coefficients and use either index, frequency or period as abscissas.
1325
You can choose between direct and inverse Fourier transforms. If you
1326
specify real input data, X is assumed to be equally spaced and
1327
ignored; if you specify complex input data X is taken as the real part
1328
and Y as the imaginary part.
1318
1330
If Grace was configured with the FFTW library (see <ref
1319
1331
name="configuration" id="configuration">), then the DFT and
1411
1423
can be saved in a file and retrieved as needed using the file
1412
1424
menu of the popup.
1414
In the "Advanced" tab, you can additionally apply a restriction to the
1415
set(s) to be fitted (thus ignoring points not satisfying the
1416
criteria), use one of preset weighting schemes or define your own,
1417
and choose whether to load the fitted values, the residuals or
1418
the function itself. Choosing to load fitted values or residuals leads
1419
to a set of the same length and abscissas as the initial set. Choosing
1420
to load the function is almost similar to load the fitted values
1421
except that you choose yourself the boundaries and the number of
1422
points. This can be used for example to draw the curve outside of the
1423
data sample range or to produce an evenly spaced set from an irregular
1426
In the "Advanced" tab, you can additionally apply a restriction to
1427
the set(s) to be fitted (thus ignoring points not satisfying the
1428
criteria), use one of preset weighting schemes or define your own
1429
(notice that "dY" in the preset "1/dY^2" one actually refers to the
1430
third column of the data set; use the "Custom" function if this
1431
doesn't make sense for your data set), and choose whether to load
1432
the fitted values, the residuals or the function itself. Choosing
1433
to load fitted values or residuals leads to a set of the same
1434
length and abscissas as the initial set. Choosing to load the
1435
function is almost similar to load the fitted values except that
1436
you choose yourself the boundaries and the number of points. This
1437
can be used for example to draw the curve outside of the data
1438
sample range or to produce an evenly spaced set from an irregular
1426
1441
<sect3> Correlation/covariance <label id="correlation/covariance">
1429
1444
of one set or cross correlation between two sets. You only
1430
1445
select the set (or sets) and specify the maximum lag. A check
1431
1446
box allows one to evaluate covariance instead of correlation.
1447
The result is normalized so that abs(C(0)) = 1.
1433
1449
<sect3> Digital filter <label id="digital-filter">
1683
1699
the font tool, the character or command will be inserted at this
1684
1700
position, not at the end of the string!
1702
Most of the controls in the dialog should be self-explanatory. One
1703
that is not (and frequently missed) is the "Axis transform"
1704
input field in the "Tick labels" tab. Entering there e.g. "-$t"
1705
will make the tick labels show negates of the real coordinates their
1706
ticks are placed at. You can use any expression understood by the
1707
interpreter (see <ref id="command-interpreter"
1708
name="command interpreter">).
1686
1710
Once you have set the options as you want, you can apply
1687
1711
them. One useful feature is that you can set several axes at
1688
1712
once with the bottom pulldown menu (current axis, all axes
1890
1914
set <it>nn</it> in the current graph|
1891
1915
<it>nn</it>: 0-99 |
1894
the last allocated set in the current graph|
1918
the last implicitly (i.e. as a result of a data transformation) allocated set in the current graph|
1898
1922
the active set in the current graph|
2047
2071
In numerical expressions, the infix format is used. Arguments of
2048
2072
both operators and functions can be either scalars or vector arrays.
2073
Arithmetic, logical, and comparison operators are
2074
given in tables below.
2052
2078
<table loc="htbp">
2138
Another conditional operator is the "?:" (or ternary) operator, which
2139
operates as in C and many other languages.
2141
(expr1) ? (expr2) : (expr3);
2143
This expression evaluates to expr2 if expr1 evaluates to TRUE, and
2144
expr3 if expr1 evaluates to FALSE.
2112
2147
<table loc="htbp">
2113
2148
<tabular ca="ll">
2141
2176
rand | pseudo random number distributed uniformly on (0.0,1.0) @
2142
2177
rand(n) | array of n random numbers @
2143
2178
rint(x) | round to closest integer @
2179
rsum(x) | running sum of x @
2144
2180
sin(x) | sine function @
2145
2181
sinh(x) | hyperbolic sine @
2250
2286
AVG(x) | average of array x @
2251
2287
SD(x) | standard deviation of array x @
2252
2288
SUM(x) | sum of all elements of array x @
2289
INT(x,y) | integral of y dx @
2290
IMIN(x) | index of min value of array x @
2291
IMAX(x) | index of max value of array x @
2261
2300
<sect1>Procedures
2263
2302
Methods of directly manipulating the data corresponding to the
2264
Data|Transformation menu are described in table
2265
<ref id="transformations">.
2303
Data|Transformation menu are described in table <ref
2304
id="transformations">. To evaluate expressions, you can directly submit
2305
them to the command interpreter like you would in the evaluate expression
2306
window. As an example, S1.X = S1.X * 0.000256 scales the x-axis
2307
coordinates. The functionality of the 'Sample points' menu entry can be
2308
obtained through RESTRICT.
2267
2310
<table loc="htbp">
2268
2311
<tabular ca="p{3cm}p{5cm}p{3.5cm}p{3cm}">
2270
2313
Statement | Description | Types | Example @
2315
RUNAVG (set, npoints) |
2316
running average of <it>set</it> using <it>npoints</it> number of points |
2317
nexpr <it>npoints</it> |
2319
RUNMED (set, npoints) |
2320
running median of <it>set</it> using <it>npoints</it> number of points |
2321
nexpr <it>npoints</it> |
2323
RUNMIN (set, npoints) |
2324
running minimum of <it>set</it> using <it>npoints</it> number of points |
2325
nexpr <it>npoints</it> |
2327
RUNMAX (set, npoints) |
2328
running maximum of <it>set</it> using <it>npoints</it> number of points |
2329
nexpr <it>npoints</it> |
2331
RUNSTD (set, npoints) |
2332
running standard deviation of <it>set</it> using <it>npoints</it> number of points |
2333
nexpr <it>points</it> |
2272
2335
INTERPOLATE (set, mesh, method, strict) |
2273
2336
interpolate <it>set</it> on a sampling <it>mesh</it> using <it>method</it>. <it>strict</it> flag controls whether result should be bound within the source set |
2274
2337
vexpr <it>mesh</it>, <it>method</it>: one of LINEAR, SPLINE, and ASPLINE, onoff <it>strict</it> |
2284
2347
RESTRICT (set, restriction) |
2285
2348
filter <it>set</it> according to logical <it>restriction</it>. The original set will be overwritten |
2286
2349
vexpr <it>restriction</it> |
2287
RESTRICT (S0, x < 0) @
2350
RESTRICT (S0, S0.X < 0) @
2288
2351
RESTRICT (set, region, negate) |
2289
2352
filter <it>set</it> by keeping only points lying inside/outside <it>region</it>. The original set will be overwritten |
2290
2353
onoff <it>negate</it>|
2291
RESTRICT (S0, x < 0) @
2354
RESTRICT (S0, R1, OFF) @
2358
2413
HELP <it>url</it> |
2359
2414
open a HTML document pointed to by <it>url</it> |
2415
sexpr <it>url</it> |
2361
2416
HELP "doc/FAQ.html" @
2363
2418
open User's Guide |
2430
scale the graph in x only |
2434
scale the graph in y only |
2438
scale to a specific set |
2446
refresh the canvas to reflect the current project state |
2450
sleep for <it>n</it> seconds |
2454
update the GUI (graph and set selectors etc) to reflect the current project state |
2457
SAVEALL <it>"file"</it> |
2458
save project to <it>file</it> |
2459
sexpr <it>file</it> |
2461
LOAD <it>"file"</it> |
2462
load project <it>file</it> |
2463
sexpr <it>file</it> |
2506
2605
expr <it>ymin</it>| VIEW YMIN .25 @
2507
2606
VIEW YMAX <it>ymax</it> | Sets top edge of current graph at y=<it>ymax</it> in the viewport |
2508
2607
expr <it>ymax</it>| VIEW YMAX .75 @
2608
VIEW <it>xmin</it>, <it>ymin</it>, <it>xmax</it>, <it>ymax</it>| Sets graph's viewport |
2609
expr <it>xmin</it>, <it>ymin</it>, <it>xmax</it>, <it>ymax</it>| VIEW 0.15, 0.15, 1.15, 0.85 @
2509
2610
XAXES SCALE <it>type</it> | Set scaling of the x axes to <it>type</it> |
2510
2611
<it>type</it>: one of NORMAL, LOGARITHMIC, or RECIPROCAL | XAXES SCALE NORMAL @
2511
2612
YAXES SCALE <it>type</it> | Set scaling of the y axes to <it>type</it> |
2533
2634
Statement | Description | Types | Example @
2535
2636
TITLE <it>title</it> | Sets the title of current graph |
2536
qstr <it>title</it> | TITLE "Foo" @
2637
sexpr <it>title</it> | TITLE "Foo" @
2537
2638
TITLE FONT <it>font</it> | Selects font of title string |
2538
2639
fontsel <it>font</it> | TITLE FONT 1 @
2539
2640
TITLE SIZE <it>size</it> | Sets size of title string |
2541
2642
TITLE COLOR <it>color</it> | Sets color of title string |
2542
2643
colorsel <it>color</it> | TITLE COLOR 1 @
2543
2644
SUBTITLE <it>subtitle</it> | Sets the subtitle of current graph |
2544
qstr <it>subtitle</it> | SUBTITLE "Bar" @
2645
sexpr <it>subtitle</it> | SUBTITLE "Bar" @
2545
2646
SUBTITLE FONT <it>font</it> | Selects font of subtitle string |
2546
2647
fontsel <it>font</it> | SUBTITLE FONT "Times-Italic" @
2547
2648
SUBTITLE SIZE <it>size</it> | Sets size of subtitle string |
2612
2713
Statement | Description | Types | Example @
2614
READ <it>file</it> | Reads <it>file</it> as a single set |
2615
qstr <it>file</it> | READ "foo.dat" @
2616
READ <it>settype</it> <it>file</it> | Reads <it>file</it> into a single set of type <it>settype</it> |
2617
xytype <it>settype</it>, qstr <it>file</it> | READ xydy "bar.dat" @
2618
READ NXY <it>file</it> | Reads <it>file</it> as NXY data |
2619
qstr <it>file</it> | READ NXY "gad.dat" @
2620
READ BLOCK <it>file</it> | Reads <it>file</it> as block data |
2621
qstr <it>file</it> | READ BLOCK "zooks.dat" @
2715
READ <it>"file"</it> | Reads <it>file</it> as a single set |
2716
sexpr <it>file</it> | READ "foo.dat" @
2717
READ <it>settype</it> <it>"file"</it> | Reads <it>file</it> into a single set of type <it>settype</it> |
2718
xytype <it>settype</it>, sexpr <it>file</it> | READ xydy "bar.dat" @
2719
READ NXY <it>"file"</it> | Reads <it>file</it> as NXY data |
2720
sexpr <it>file</it> | READ NXY "gad.dat" @
2721
READ BLOCK <it>"file"</it> | Reads <it>file</it> as block data |
2722
sexpr <it>file</it> | READ BLOCK "zooks.dat" @
2622
2723
BLOCK <it>settype</it> <it>columns</it> | Forms a data set of type <it>settype</it> using <it>columns</it> from current block data file. |
2623
xytype <it>settype</it>, qstr <it>columns</it> | BLOCK xydxdy "0:2:1:3" @
2724
xytype <it>settype</it>, sexpr <it>columns</it> | BLOCK xydxdy "0:2:1:3" @
2725
WRITE <it>set</it> | writes <it>set</it> to stdout|
2726
setsel <it>set</it> | WRITE G0.S1 @
2727
WRITE <it>set</it> FORMAT <it>"formatstring"</it> | writes <it>set</it> to stdout using format specification <it>formatstring</it> |
2728
setsel <it>set</it> sexpr <it>formatstring</it> | WRITE G0.S1 FORMAT "%18.8g" @
2729
WRITE <it>set</it> FILE <it>"file"</it> | writes <it>set</it> to <it>file</it> |
2730
setsel <it>set</it> sexpr <it>file</it> | WRITE G0.S1 FILE "data.dat" @
2731
WRITE <it>set</it> FILE <it>"file"</it> FORMAT <it>"formatstring"</it> | writes <it>set</it> to <it>file</it> using format specification <it>formatstring</it> |
2732
setsel <it>set</it> sexpr <it>file</it> sexpr <it>formatstring</it> | WRITE G0.S1 FILE "data.dat" FORMAT "%18.8g" @
2626
2735
<label id="set-io">
2791
2900
int GraceOpenVA | (char *<it>exe</it>, int <it>buf_size</it>, ...)
2792
2901
| launch a Grace executable <it>exe</it> and open a communication channel with it using <it>buf_size</it> bytes for data buffering. The remaining NULL-terminated list of options is command line arguments passed to the Grace process @
2793
2902
int GraceOpen | (int <it>buf_size</it>)
2794
| equivalent to GraceOpenVA("xmgrace", buf_size, "-noask", NULL) @
2903
| equivalent to GraceOpenVA("xmgrace", buf_size, "-nosafe", "-noask", NULL) @
2795
2904
int GraceIsOpen | (void) | test if a Grace subprocess is currently connected @
2796
2905
int GraceClose | (void) | close the communication channel and exit the Grace subprocess @
2797
2906
int GraceClosePipe | (void) | close the communication channel and leave the Grace subprocess alone @
2840
<p> There is no fortran equivalent for the GracePrintf function,
2949
<p> There is no Fortran equivalent for the GracePrintf function,
2841
2950
you should format all the data and commands yourself before
2842
2951
sending them with GraceCommandF.
2844
The Grace subprocess listen for the commands you send and
2845
interpret them as if they were given in a batch file. You can
2953
The Grace subprocess listens for the commands you send and
2954
interprets them as if they were given in a batch file. You can
2846
2955
send any command you like (redraw, autoscale, ...). If you want
2847
2956
to send data, you should include them in a command like "g0.s0
2848
2957
point 3.5, 4.2".
2939
3048
</code></tscreen>
3050
To compile this program, type
3052
cc example.c -lgrace_np
3054
If Grace wasn't properly installed, you may need to instruct the
3055
compiler about include and library paths explicitly, e.g.
3057
cc -I/usr/local/grace/include example.c -L/usr/local/grace/lib -lgrace_np
2941
3060
<sect1>FFTW tuning<label id="fftw-tuning">
2986
3105
Grace type | Description @
2988
f_of_i | a function of 1 <tt/int/ variable @
2989
f_of_d | a function of 1 <tt/double/ variable @
2990
f_of_nn | a function of 2 <tt/int/ parameters @
2991
f_of_nd | a function of 1 <tt/int/ parameter and 1 <tt/double/ variable @
2992
f_of_dd | a function of 2 <tt/double/ variables @
2993
f_of_nnd | a function of 2 <tt/int/ parameters and 1 <tt/double/ variable @
2994
f_of_ppd | a function of 2 <tt/double/ parameters and 1 <tt/double/ variable @
2995
f_of_pppd | a function of 3 <tt/double/ parameters and 1 <tt/double/ variable @
3107
f_of_i | a function of 1 <tt/int/ variable @
3108
f_of_d | a function of 1 <tt/double/ variable @
3109
f_of_nn | a function of 2 <tt/int/ parameters @
3110
f_of_nd | a function of 1 <tt/int/ parameter and 1 <tt/double/ variable @
3111
f_of_dd | a function of 2 <tt/double/ variables @
3112
f_of_nnd | a function of 2 <tt/int/ parameters and 1 <tt/double/ variable @
3113
f_of_ppd | a function of 2 <tt/double/ parameters and 1 <tt/double/ variable @
3114
f_of_pppd | a function of 3 <tt/double/ parameters and 1 <tt/double/ variable @
3115
f_of_ppppd | a function of 4 <tt/double/ parameters and 1 <tt/double/ variable @
3116
f_of_pppppd | a function of 5 <tt/double/ parameters and 1 <tt/double/ variable @
3347
3468
<item> PDF driver:
3349
<item> patterned fills are not implemented
3350
3470
<item> bitmapped text strings are not transparent
3352
3472
<item> MIF driver:
3353
the driver is a brand new one and still in beta test
3355
3474
<item> some of patterned fills not implemented
3356
3475
<item> bitmapped text strings not implemented
3358
3477
<item> SVG driver:
3359
the driver is a brand new one and still in beta test
3361
<item> patterned fills not implemented
3362
3479
<item> bitmapped text strings not implemented
3430
3547
Command | Description @
3432
PDF1.2 | set compatibility mode to PDF-1.2 @
3433
3549
PDF1.3 | set compatibility mode to PDF-1.3 @
3550
PDF1.4 | set compatibility mode to PDF-1.4 @
3434
3551
compression:value | set compression level (0 - 9) @
3552
patterns:on | enable use of patterns @
3553
patterns:off | disable use of patterns @