![]() |
Docs: linegraf
Linegraf (E1) plots a graph on a display device according to formatting specifications and data which are acquired from files or from the standard input. Unlike previous incarnations of this program, the current version of linegraf can read data from separate data files or from the format file. Linegraf now utilizes the standard graphics commands and options, and the user who is unfamiliar with these should read the Multiplot User's Manual before attempting to use linegraf.
Linegraf is invoked as:
Linegraf is really quite easy to use, but it is perhaps best to look at an example of a format file and the plot that it generates before reading about the details of the commands (a formal explication of the contents of the data and format files can be found after the following example). The graph generated by the format file for this example is shown in Figure 1. The file that produced Figure 1 contains the following:
trace data1 circle nolines color=2 # Specifies data from file 'data1' trace data2 square nolines color=3 # Specifies data from file 'data2' tmargin .2 # Leave a margin at the top textstyle textsize=4 complex # Text style for legend and titles legend data1 "Controls" # Legend for data1 with label "Controls" legend data2 "Patients" # Legend for data2 with label "Patients" title "RT as a Function of Set Size" textsize=5 # Titles title "Patients vs. Controls" xtitle "Set Size" simplex ytitle "RT" simplex xmin 0 # X & Y minima, maxima, # of ticks xmax 5 nxticks 6 ymin 300 ymax 800 nyticks 6 gridstyle medium # Line style for grid draw # Draw graph coord graph # Change to graph coordinate system line 0 300.5 5 799.4 dotted color=2 # Draw regression lines line 0 384.0 5 732.6 dashed color=3 coord screen # Change back to screen coordinates text 0.08 1.14 "Figure 1" textsize=3 italicsWhile some of the specific commands may be unclear, the basic format and manner in which linegraf works should be apparent from this example. The remainder of this document simply explains the details of the linegraf commands, most of which were used in this example.
The trace command is used to specify the name of a file containing the data to be plotted. Normally, the data for separate traces are stored in separate files. Each line of data represents a single point on the graph, and consists of the x value, the y value, and an optional error value. The error value can be preceded by a plus or minus if only the positive or negative half of the error bar should be plotted. For example, the file 'data1' contains:
1 403 10 2 496 -20 4 701 +28If desired, the data can alternatively be placed in the format file, directly following the relevant trace command. This is accomplished by specifying "none" as the filename and by placing the word "end" at the end of the data, as in:
trace none 1 403 10 2 496 -20 4 701 +28 endThe data for multiple traces can also be placed in a single file, with the word "end" following the data for each trace. Each time a trace command occurs with a particular filename, data are read from the corresponding data file beginning at the current position and continuing until the "end" statement. For example, the data for both traces in figure 1 could be stored in a single file named "data", which would look like this:
1 403 10 2 496 -20 4 701 +28 end 1 458 12 2 517 +18 4 665 -30and the trace commands would appear as:
trace data circle nolines color=2 trace data square nolines color=3
The parameters controlling the format of the plot are defined in a file that contains a list of commands, each having various mandatory and optional parameters. An editor such as vi (1) is typically used to create this file. Linegraf (E1) uses the standard ERPSS command processing interface, which is described in the Multiplot User's Manual. Briefly, each command consists of a command name, possibly followed by a set of mandatory parameters and finally by a set of optional parameters. Each parameter is a single argument, which means that it can contain no spaces or tabs unless enclosed in double quotes. Normally, each line consists of a single command and its parameters. Many of the linegraf commands use the standard graphics options that are described in the documentation for plotcmd (E3p), and these will be abbreviated as "line_opts", "text_opts", and "trans_opts" for line, text, and translation options, respectively.
trace datafile [x=file/line[*value[+value]] yoff=value line_opts symboltype radius=value nolines nosymbols]
The trace command specifies a file containing a set of data that will be used for a single trace when the graph is drawn. All of the trace commands should appear at the beginning of the format file, before any other commands. If "none" is specified for the file name, the data are read from the format file until the string "end" is encountered on a line by itself. If "-" is specified, then the data are read from the standard input.
The x= option can be used to determine if the x-value for each data point is specified in the data file (x=file, the default), or if it should be derived from the line number of each y-value (x=line). The x-value might be derived from the line number when, for example, the erptoasc (E1) program has been used to create an ascii version of an ERP waveform that contains only the voltages and not the time points. In such a case, the x-value can be derived from the line number along with two additional steps of multiplication and addition: the time point equals the line number multiplied by the sampling interval minus the prestimulus period (e.g., x=line*4-100 would be used for a sampling rate of 250 Hz with a 100 msec prestimulus interval). The multiplication and addition steps are optional, and can be used to transform x-values that are derived from the data file or from the line number. The multiplication is conducted before the addition, and while the multiplication value can be specified without the addition value, the converse is not true. The term "line number" is a bit misleading in the context of this option: "line" actually refers to the ordinal position of the line within a particular data set, excluding lines without data values. For example, if the data for a trace is found within the format file, the "line number" will start at 1 for the first data point after the trace command, independent of the actual line number within the file.
The yoff option is used to add a constant value to all data points within a trace. This is useful in some cases, such as baselining a set of data or displaying multiple traces with different offsets (usually without axes).
The symboltype option is used to specify a particular shape for the symbol that is plotted at each point, and can be selected from: circle, opencircle, triangle, opentriangle, square, opensquare, hexagon, and openhexagon. A default value is used if no symbol type is specified. The size is controlled by the radius= option, which specifies the radius of the symbol as a proportion of the width of the screen. The symbols can be suppressed by the nosymbols option and the lines that are drawn between points can be suppressed by the nolines option.
legend tracefile/tracenumber "label" [line_opts symboltype radius=value]
This command plots a legend with the symbol parameters that were used for plotting data from the file named tracefile, giving it the label specified by "label". Because multiple data sets can be contained in a single file, the trace number (tracenumber) can be specified instead of the trace name (e.g., "3" would be used for the third trace). By default, the legend for a particular trace will use the same symbol and radius as that trace, but a different symboltype and radius can be specified by the same options used for the trace command.
title string [text_opts] or header string [text_opts]
xtitle string [text_opts] or xlabel string [text_opts]
ytitle string [text_opts] or ylabel string [text_opts]
These commands plot titles for the entire graph, the x-axis or the y-axis (to retain some backwards compatibility, two equivalent names are provided for this set of three functional commands). The entire graph can be given several titles, which are plotted on consecutive lines, but the x and y axes may have only one title each.
gridstyle [line_opts axes box grid none]
This command is used to determine the line style values that will be used to draw the lines surrounding the graph, and whether these lines will consist of the x and y axes, a box, or a grid. If none is specified, the grid and axis labels are not drawn.
xmin value
xmax value
ymin value
ymax value
limitx
limity
These commands allow the user to specify the minimum and maximum values for the x and y axes. By default, linegraf uses values derived from the minimum and maximum values within the data sets. Again, by default, linegraf will plot all values, even if they exceed those limits. However, if the limitx or limity commands are given, only points falling within the specified minimum and maximum values will be plotted.
lmargin value
tmargin value
rmargin value
bmargin value
These commands are used to control the size of the overall graph, and specify blank margins at the left, top, right, and bottom sides of the graph, respectively. The margins are specified as proportions of the width of the screen (e.g., .20 for 20% of the width).
nxticks value
nyticks value
These commands specify the number of ticks that should be used on the x and y axes, respectively.
xtickstyle [format=fw.prec text_opts]
ytickstyle [format=fw.prec text_opts]
These commands control the style of the numbers or labels that are plotted at each tick. The fw portion of the format= option specifies the total number of characters printed for each number (the field width), and the prec portion specifies the number of digits to the right of the decimal point (the precision). For C buffs, the fw.prec string is used in a printf floating point format string between the '%' character and the 'f' character (e.g., format=3.2 would result in a printf format of "%3.2f").
autoxtickoff
autoytickoff
These commands disable the automatic tick labels for the x and y axes, respectively. This is useful when user-defined tick marks are used, as discussed below.
xtick x_value [label=string text_opts]
ytick y_value [label=string text_opts]
These commands allow the user to put tick marks at particular places on the x and y axes, respectively (usually after disabling the automatic tick labels, as discussed above). If a label is specified with the label= option, that label is printed instead of x_value or y_value, which specify the position of the tick.
symbol x y symboltype [line_opts radius=value]
This command plots the named symbol (e.g., square) at the specified location.
draw
coord screen/graph
The draw command causes the graph specified by the preceding format commands to be drawn. If this command is not specified, the graph is simply drawn after the entire format file has been processed. The only reason for the existence of this command is that the graph must be drawn before the coord command can be used. The coord command controls whether the coordinate system used to specify locations for various commands is the usual screen system (0.0 to 1.0 for the x axis and 0.0 to 0.75 for the y axis in landscape mode or 0.0 to 1.33 for the y axis in portrait mode), or the graph system (which uses the values of the graph's x and y axes to determine the placement of objects). Once the graph has been drawn, it is possible to go back and forth between the screen and graph systems.
readfile filename [trans_opts]
This command causes linegraf to read the format commands located in the file named filename, using the translation, rotation, and scaling options.
In addition to the commands listed above, all of the standard graphics commands that are available for multiplot (E1) are also available for linegraf (E1).
legend tracefile/tracenumber "label" [line_opts symboltype radius=value] trace datafile [x=file/line[*value[+value]] line_opts symboltype radius=value nolines nosymbols] title string [text_opts] or header string [text_opts] xtitle string [text_opts] or xlabel string [text_opts] ytitle string [text_opts] or ylabel string [text_opts] xmin value xmax value ymin value ymax value lmargin value tmargin value rmargin value bmargin value nxticks value nyticks value xtickstyle [format=value text_opts] ytickstyle [format=fw.prec text_opts] autoxtickoff autoytickoff xtick x_value [label=string text_opts] ytick y_value [label=string text_opts] draw coord screen/graph readfile filename [trans_opts]
linestyle [line options] gridstyle [line options] textstyle [line and text options] point x y [line options] line x1 y1 x2 y2 [line options] moveto x y lineto x y [line options] arrow x1 y1 x2 y2 length angle [line_options] arc mid_x mid_y radius start_degrees stop_degrees [line options] rect left top right bottom [line options fill=value] startpgon endpgon drawpgon x y [line options fill=value] text x y "string" [line and text options] translate [translation options] trans [translation options] vfile filename [translation options]
![]()