home *** CD-ROM | disk | FTP | other *** search
- NAME
- graph - plot a tabulated function
-
- SYNOPSIS
- graph [file file file] [options]
-
- DESCRIPTION
- Graph takes pairs of points (two numbers per line) from the given
- file as x- and y- values and plots them on the screen, connected by
- straight lines. A string surrounded by quotes "..." may follow a
- pair of points. This string is a "point label", and will be
- displayed starting at that point. The program draws axes with
- convenient labels (integers times powers of 1000), plots the data,
- waits for a keypress, then resets the screen parameters and clears
- the screen before exiting.
-
- If no file is specified on the command line, data is read from the
- standard input, which may be redirected. If data is entered from
- the keyboard, end of data is signaled by typing <cntl>Z.
-
- In the data, blank lines and lines beginning with ';' are ignored.
-
- More than one input file can be specified. All the data will
- be read before scaling parameters are calculated. The plot
- will be "broken" at the end of each file. That is, there will
- be no line connecting the last point of the first file with the
- first point of the second file. Similarly, if a line starts
- with a null byte (that is, if a line feed is followed by a
- null) the plot will be broken. Separate curves may also be
- delimited with a point label on the same line as the last point
- on the curve, or by a null byte immediately following the last
- point (see the -b switch).
-
- The -m switch can be used to select the line style or marker
- style for each curve. If both markers and connecting lines are
- wanted, list the data file twice and specify different styles.
- For example,
-
- graph gamma gamma -m 1 -30
-
- would give red squares connected by white solid lines on an EGA.
-
- Graph should no longer leave the display in a nonstandard mode. If it
- does, please let me know. In the mean time, the display can be
- restored using the DOS command MODE:
-
- mode co80 or mode mono
-
- as appropriate.
-
- OPTIONS
- Options can appear before, among, or after input file names
- provided a file name cannot be mistaken for the parameter of an
- option.
-
- &<name> (hard copy versions only) Device driver switches are
- in the configuration file <name>. See "DEVICE DRIVER
- CONFIGURATION FILES" below.
-
- @<name> or -f <name>
- More parameters (filenames and/or switches) are in the script
- file <name>. This can be used for lists of parameters
- that are too long for a command line, or merely to save
- retyping lists of parameters. The parameters in the
- script file have the same format as those on the
- command line, but may be separated by linefeeds as well
- as spaces or tabs. More than one script file switch
- may appear on the command line, and script files may
- refer to other script files to any depth. All the
- script files will be read. For example, if the file
- "curves" contains the line
- parabola elipse circle
- and the file "options" contains the lines
- -g -e -m 20 30 40
- then the command
- A>graph @curves @options
- is equivalent to
- A>graph parabola elipse circle -g -e -m 20 30 40
- In a script file, a semicolon introduces a comment that
- extends to the end of the line.
-
- -a [<step> [<start>]]
- Automatically generate abscissas. The first argument,
- if present, is the step between values (default 1).
- The second argument, if present, is the starting value
- (default 0, or first argument from -x switch).
-
- -b break (disconnect) the plot after each label. (See
- switch -m to plot the line segments with different
- linestyles. To break the plot without printing labels,
- use empty labels: "".) This option is set automatically
- if more than one input file or more than one linestyle
- is specified.
-
- -c <text> argument is default label for data points
-
- -e equal vertical and horizontal scales (same number of
- inches on the display per unit in problem space), so that
- circles don't look like elipses
-
- -f <name> See @<name>.
-
- -g -g with no arguments eliminates the axes.
-
- -g <style> <tics> <width>
- First argument is grid style:
- 0 = no grid and no numeric labels,
- 1 = frame with tic marks inside (default),
- -1 = frame with tic marks outside the graph area,
- 2 = full grid
- 3 = bottom and left axes only
- -3 = bottom and left axes, tic marks on outside.
- 4 = bottom and left axes only, separated from plot
- -4 = bottom and left axes, separated from plot,
- tic marks on outside.
- Second argument is approximate number of small
- tic marks per numeric label (1 to 10, default 5). Set
- <tics> to 1 to eliminate small tic marks. Third
- argument is width of grid lines (default 1).
-
- -l <text> next argument is label for graph (printed at top). If the
- label starts with a double quote it may contain spaces:
- -l "three cornered hat"
-
- -m <n1> <n2> <n3>...
- numeric arguments are linestyles for successive line
- segments (see switch -b). Each positive argument is a
- number of up to three hex digits WCS, where
- W is the linewidth (0-9, with 0 giving width 1),
- C is the color (0-f, with 0 being brightest), and
- S is linestyle (1-5, 1 for solid, 2 for dashed,
- 3 for dotted, etc.)
- If an argument is -1, the data points are plotted as
- dots not connected by lines. In general, a negative
- argument -CS generates a marker:
- C is the color (0-f, with 0 being brightest), and
- S is the marker style (0-9 for box, dot, plus,
- asterisk, hexagon, cross, box, diamond,
- triangle with point down, triangle with point
- up)
-
- The special style FF causes a curve not to be displayed
- at all. An argument can also include a repeat count,
- as in 3*45 or 4*-205.
-
- The -m switch will use as many of the following
- parameters as appear to be hex numbers, either negative
- or positive, noteably including the switches -a through
- -f. This misinterpretation may be avoided by putting
- the -m switch and its arguments last in the command
- line.
-
- -n Omit numeric labels on axes. This uses more of the screen
- for the graph, therefore effectively increases
- resolution slightly. It may also be used when you want
- to make a hard copy and label it with a typewriter. To
- eliminate both grid and labels, but keep the plot
- scaling the same as if labels were printed, use "-g"
- alone. For plotter versions, this can be used to add
- more curves to an existing graph.
-
- -t Transpose x and y values before plotting (-x now refers to
- vertical axis).
-
- -x[l] [min [max [junk]]]
- If l is present, x axis is logrithmic. First argument,
- if present, is lower x limit. Second argument, if
- present, is upper x limit. A third numeric argument
- may be present but will be ignored. By default, these
- values are determined automatically.
-
- -y[l] [min [max [junk]]]
- Similarly for y axis
-
- -y[l]m [min [max [junk]]]
- -ya[p] [min [max [junk]]]
- -yp[p] [min [max [junk]]]
- Any of these signal that each line of the input
- contains the real and imaginary parts of a complex
- number (after the abscissa, unless -a is also used).
- An 'm' requests that the magnitude of the number
- (square root of sum of squares of real and imaginary
- parts) be plotted. 'p' or 'a' requests the phase
- (atan(imaginary part/real part), also known as the
- argument) be plotted. The signs of both parts are
- taken into account, so the phase ranges from -pi to
- +pi. If both real and imaginary parts are zero, the
- phase is arbitrarily assumed to be zero. An additional
- 'p' requests that the phase be divided by pi before
- plotting.
-
- -h <n> argument is the fraction of the vertical space to be
- used for the graph.
-
- -u <n> argument is the fraction of the vertical space to move
- up before plotting.
-
- -w <n> argument is the fraction of the horizontal space to be
- used for the graph (useful if screen dump routine
- doesn't dump the entire width of the screen).
-
- -r <n> argument is the fraction of the horizontal space to move
- right before plotting.
-
- INTERACTIVE USE
-
- Several attempts are sometimes required to get the display
- options set correctly. There are two ways to simplify this
- process. The first is to use the command line edit facilities
- provided by DOS. To add an option: return to DOS, type F3 to
- redisplay the previous command, add the option, and type
- <return>. You can use also use this procedure to invoke a
- hardcopy version of GRAPH with the same options. A more
- powerful command line editor like CED makes this procedure
- easier. The disadvantage is that both GRAPH and the data must
- be read in each time, which can be slow.
-
- In display versions of GRAPH, the user may also adjust display
- options interactively via a series of pop-up menus. To display the
- top level menu, type a slash '/'. The highlighted option may be
- selected by typing <return> (sometimes labeled <enter>). Any
- options may be selected by typing the initial letter.
-
- >> The following mouse functions may be expected in a future
- >> version. In the mean time, all menu functions can be
- >> selected via the keyboard.
-
- If a mouse or other pointing device and a Microsoft-equivalent
- driver (MOUSE.COM or MOUSE.SYS) are installed, the mouse may also
- be used to adjust parameters. Mouse commands are of three kinds.
- "Pressing" a mouse button has an effect which doesn't depend on the
- location of the cursor. "Clicking" means to point with the cursor
- and press the left mouse button quickly. "Dragging" means to point
- one place with the cursor, press the left button, and hold it down
- while moving the cursor to another place.
-
- Pressing the left mouse button will pop up the top level menu and
- make the mouse cursor visible. On a two- or three-button mouse,
- pressing the right button is equivalent to pressing <esc> on the
- keyboard. This will clear the most recent menu or, if there is no
- menu, terminate the program. When the top level menu is cleared,
- the data are redisplayed using the new settings. (You may
- envision the left button sending you further "in", and the right
- button backing you "out".)
-
- When the menu is visible, an item may be selected by clicking on
- it.
-
- The cursor may be used to adjust the portion of the user's data
- space being displayed (the "window") in four ways.
-
- The X and Y menu items can be used to set limits explicitly.
-
- To zoom in, drag from one corner of the desired display area to
- the opposite corner.
-
- The "zoom" menu item zooms out - enlarges the window in all
- directions.
-
- To enlarge the area being displayed in only one direction, drag
- from somewhere near the center of the display area toward that
- edge of the display.
-
- For the first method, you must explicitly request a redisplay. For
- the other methods, the redisplay is automatic.
-
- To save the current options for a future plot (in particular,
- for a hard copy), use the Output command under File. For
- example, if you display some data by starting with the command
-
- C>graph stuff -m 50 60 70
-
- and use the menubars to set additional options, you can get a
- hardcopy by entering
-
- / F O <return> Q
-
- followed by the DOS command
-
- C>graph stuff -f f
-
- Note that these commands use default format output file name,
- 'f'.
-
- VERSIONS
- Graph is available in several versions for different hardware.
- When necessary for configuration control, these versions are
- given different file names (see FILES section below). It is
- suggested that the "normal" version for a given computer be
- renamed GRAPH for simplicity. Two measures are taken to ensure
- no damage is done by inadvertently executing the wrong version.
- First, any version of graph can be executed with a question
- mark as the only parameter:
-
- GRAPH ?
-
- It will then print a help screen which indicates the hardware it
- supports, and exit immediately without accessing any
- machine-specific hardware. Second, graph tests that the hardware
- it needs is present before using it (except for the plotter and
- laser printer versions).
-
- For the display version of GRAPH, you will need a device driver in the
- form of a .BGI (for Borland Graphics Interface) appropriate for
- your hardware. If you have one of the following standard graphics
- cards, you can use one of those supplied by Borland:
-
- CGA
- MCGA
- EGA
- ATT400
- VGA
- PC3270
- IBM8514
- Hercules mono
-
- If so, you need only put the .BGI file where GRAPH can find it. GRAPH
- will look in the directories listed in the environment variable
- BGIPATH if it is set, otherwise it will look in the directories
- indicated by PATH. For example:
-
- C>set bgipath=C:\MY\BGIFILES;C:\TC\BGI
- C>graph mydata
-
- If you put both GRAPH.EXE and the required .BGI file into one of the
- directories in your PATH, you will not need to add anything to
- your environment.
-
- If you want to select a particular graphics mode, you may set the
- environment variable GRAPHMODE to one of the numeric constants of
- "graphics_modes" enumeration type as defined by Borland. The
- constants are as follows:
-
- mode value
- ------------------ -----
- CGA 320*200 C0 0
- CGA 320*200 C1 1
- CGA 320*200 C2 2
- CGA 320*200 C3 3
- CGA 640*200 4
-
- MCGA 320*200 C0 0
- MCGA 320*200 C1 1
- MCGA 320*200 C2 2
- MCGA 320*200 C3 3
- MCGA 640*200 4
- MCGA 640*480 5
-
- EGA 640*200 0
- EGA 640*350 1
- EGAMONO 640*350 3
-
- HERC 720*348 0
-
- ATT400 320*200 C0 0
- ATT400 320*200 C1 1
- ATT400 320*200 C2 2
- ATT400 320*200 C3 3
- ATT400 640*200 4
- ATT400 640*400 5
-
- VGA 640*200 0
- VGA 640*350 1
- VGA 640*480 2
-
- PC3270 720*350 0
-
- IBM8514 640*480 0
- 1024*768 0
-
- ...where C0, C1, C2, and C3 refer to the four palettes on the CGA
- and compatible systems.
-
- If you have nonstandard video hardware, you will have to obtain or
- write a .BGI file. In that case, set the environment variable
- BGIDRIVER to the name of the file. For example, if your driver
- is named SGA.BGI, you would set the environment variable as
- follows:
-
- C>set bgidriver=SGA
-
- No hardware autodetection of nonstandard video cards is supported.
-
-
- For the Houstin Instruments plotter, HP plotter, or LIPS-10
- laser printer, or Postscript versions, the output port may be
- specified by setting an environment variable:
-
- C>set plot_port=COM1 (the default)
- C>set plot_port=COM2
- C>set plot_port=PRN
-
- Alternately, the output can be saved in a file for later use:
-
- C>set plot_port=c:\path\filename
-
- The device driver asks about several other options: pen speed,
- margins (or pen displacement before plotting begins), and
- dimensions of desired plotting area. Note that the area
- includes space for numeric labels (unless defeated by the "-n"
- switch) and tic marks (if moved outside the graph by the "-g"
- switch).
-
- The Houstin Instruments plotter version asks which plotter is in use:
- a DMP-29, which has eight pens, or a DMP-7, which has only two. The
- DMP-29 is the default. The question can be suppressed by setting the
- environment variable PLOTTER to DMP-7 or DMP-29.
-
- By default an HI plotter is initialized with the character string
-
- \n\n\n;: EC5 V8 A 0,40 O @
-
- which the plotter interprets as follows:
-
- Carriage return (allows auto baud rate),
- plotter select, mode 1, .005" resolution,
- 8 in/sec,
- absolute mode,
- move .2 inches up and set origin,
- deselect
-
- If necessary, a different setup string may be specified using the
- environment variable "plot_setup". As with the PROMPT command in
- MS-DOS, the device driver interprets the sequence "$e" to represent
- an ASCII escape character. The escape sequences available are:
-
- $e -> escape character
- \n -> line feed
- \r -> carriage return
- \t -> tab character
- \\ -> \ (escape an otherwise special character)
- \$ -> $ (escape an otherwise special character)
-
- For example, the default setup string could be specified using the
- following command:
-
- C>set plot_setup=\n\n\n;: EC5 V8 A 0,40 O @
-
- The HP plotter version assumes an RS-232 connection with
- hardware flow control: The plotter pulls pin 20 (DTR) low to
- stop data transmission. Other conditions are set to their
- defaults. To implement this, HP recommends wiring a "null
- modem" RS-232 cable which exchanges pins 2 and 3, and connects pin
- 20 on each end to pins 5 and 6 on the opposite end. A second
- adaptor cable may be used to connect the null modem cable to the
- 9-pin connector on an IBM PC serial adaptor, or the two functions
- may be combined in a single cable. The cable schematics are as
- follows:
-
- IBM plotter
- 9-pin 25-pin 25-pin DTE
- chassis ground .. -------- 1 ---------- 1 chassis ground
- signal ground 5 -------- 7 ---------- 7 signal ground
- DTR 4 ------> 20 ------+--> 5 CTS
- +--> 6 DSR
- CTS 8 <------- 5 <---+---- 20 DTR
- DSR 6 <------- 6 <---+
- TxD 3 -------> 2 ---------> 3 RxD
- RxD 2 <------- 3 <--------- 2 TxD
-
- gender >--------->>------------>
-
- The last line indicates, for example, that the plotter has a female
- connector, so the mating cable must have a male connector. The IBM
- BIOS serial port handler will stop transmitting data when
- requested. However, it interprets the signal as an error, and
- prompts the operator with the message
-
- Not ready error writing to COM1:
- Abort, Retry, Ignore?
-
- Type "r" to continue plotting. These messages may be avoided by using
- a communications program to send the file.
-
- By default, the HP plotter is initialized with the character string
-
- DF; <esc>.R
-
- which the plotter interprets as follows:
-
- default conditions
- reset handshake to hardware flow control
- (The plotter uses RS-232 connector pin 20, or DTR.
- It pulls the pin low to stop data transmission.)
-
- If necessary, a replacement string may be specified using the
- environment variable "plot_setup", as above. The default
- setup string could be specified using the following command:
-
- C>set plot_setup=DF; $e.R
-
- The LIPS-10 version clears all macros and all fonts while
- initializing to maximize the memory space available, with the
- setup string
-
- DAF; DAM; UNIT D; SCF; FONT 2;
-
- As with the HP plotter version, the environment variable
- plot_setup can be set to a replacement string. For example,
- "DAM;" or "DAF;" can be omitted to preserve the macros or
- fonts, respectively.
-
- DEVICE DRIVER CONFIGURATION FILES
-
- The hard copy versions (GRAPHHI, GRAPHHP, GRAPHLI, GRAPHPS) can also
- accept parameters from an ASCII configuration file. Entries in
- the file are switches, some with arguments, as on a command line.
- The following switches are available:
-
- -p portrait orientation (LI and PS only)
- -l landscape orientation (the default) (LI and PS only)
- -o <xoffset> <yoffset>
- -r <xoffset>
- -t <yoffset>
- offset from top left corner of page
- -s <width> <height>
- -w <width>
- -h <height>
- plot size
- -f <name> name of output file (or port)
- -v <velocity> pen velocity (HP and HI versions only).
- Units are cm/sec for HP and in/sec for HI.
- -n <name> Plotter name (HI version only). Choices
- are "DMP-29" (the default) and "DMP-7". Case is not
- distinct, and "29" and "7" are also accepted.
-
- None of the arguments can be omitted. A semicolon introduces a
- comment that extends to the end of the line.
-
- A switch may start with '+' instead of '-', in which case it will
- establish the default, but the program will still ask for the
- final value.
-
- The device driver configuration file name will be, in decreasing order
- of priority:
-
- 1. An "&filename" entry on the command line or script file,
- 2. An "&filename" entry in the environment variable GRAPH,
- or a script file referenced by that environment
- variable.
- 3. GRAPHPS.CFG in the current directory.
-
- If more than one &filename entry appears, only the last
- configuration file referenced is read.
-
- A PostScript output file name will be, in decreasing order of
- priority:
-
- 1. The argument of the -f switch in the device
- driver configuration file,
- 2. The value of the environment variable PLOT_PORT, or
- 3. FOO.PS, where FOO is the root name of the first
- data file.
-
- Output file names for the other versions are generated similarly, but
- with extensions .HI, .HP, or .LI.
-
- FILES
- These are the currently available executable files:
-
- GRAPH.EXE IBM PC with any standard graphics adaptor
- GRAPHHI.EXE Houstin Instruments DMP-29 plotter
- GRAPHHP.EXE HP 7470A plotter
- GRAPHLI.EXE CIE Laser Image Printing System, or LIPS 10
- GRAPHPS.EXE Postscript
- GRAPHZ.EXE Zenith Z-100 (previous version with menubar)
-
- All these files have been compressed with LZEXE.
-
- NOTES
- Graph is largely equivalent to the program of the same name on
- Unix, with the following exceptions: Data may come from one or
- more files rather than the standard input. Line segments that
- go out of bounds are windowed rather than being dropped. Graph
- may adjust the specified lower or upper limits (outwards) to
- give convenient axis labels. Steps along axes may not be
- specified. The screen is always cleared before plotting. The
- default grid type is frame with tics rather than full grid.
- Axes may not be reversed by specifying a lower limit greater
- than the upper limit.
-
- UPDATE HISTORY
- 15 Jul 90 All hard copy versions accept parameters from
- a configuration file.
- 5 Jul 90 Ver 3.21: Script files may have comments.
- GRAPHPS default output filename is FOO.PS.
- 4 Jul 90 Ver 3.20: Added support for device driver
- configuration files (see &<name> switch).
- 16 Jun 90 Ver 3.19: Accepting @file as well as -f file as a
- script file reference. If a log scale switch causes a
- labeled point to be discarded, the label is
- moved to the last retained point.
- 14 Jun 90 Ver 3.18: Fetching options from environment variable
- GRAPH.
- 19 Apr 90 Ver 3.17: Displaying up to 16380 data points, if
- user memory permits.
- 6 Mar 90 Ver 3.16: allowing axes separated from graph area.
- 27 Feb 90 Ver 3.15: no longer attempts to restore video mode
- if graphics mode was never set. Fixed occasional
- divide-by-zero bug for screens with subsquare
- pixels (pixel width > pixel height, like the
- VGA).
- 19 Feb 90 Ver 3.14: No more text mode error messages if a memory
- allocation fails while in graphics mode. Coherent
- error message if script file cannot be opened.
- Default script file name is constructed from
- data file name. Menu starts at top right.
- Fixed occasional divide-by-zero bug for screens with
- subsquare pixels (pixel width > pixel height,
- like the VGA).
- 16 Sep 89 Ver 3.13: Switching to log scales no longer temporarily
- drops a linestyle. "abscissa" menu option can
- now discard y values.
- 15 Sep 89 Ver 3.12: Adding styles interactively automatically
- enables breaking, keystrokes entered during a redraw
- are not echoed through DOS when they are
- discarded.
- 13 Aug 89 Ver 3.11: Automatically adjusting width to be
- consistent with right move, etc.
- 1 Jul 89 Ver 3.10: graphics mode menus, mouse handler.
- 16 May 89 Cleaned up nonportable constructions.
- 4 May 89 Ver 3.09: user can adjust grid width & number of tic
- marks interactively. Markers don't have corner glitches.
- 25 Apr 89 Ver 3.08: not adjusting # tic marks for label size
- if no numeric labels are requested.
- 24 Apr 89 using intensity if color isn't available.
- 8 Apr 89 Ver 3.07: name of input script file becomes default for
- output script file
- 6 Apr 89 Ver 3.06: optionally writes data file names to script file
- 5 Apr 89 Ver 3.05: writes -c and -n switches to output script file
- The part of argv[] referring to data files is preserved.
- 22 Mar 89 Ver 3.04: requests correct number of tic marks in
- script file.
- 27 Feb 89 Ver 3.03: quits gracefully if there are no data points
- 23 Nov 88 Ver 3.02: Menubars allow interactive update of switches.
- 1 Aug 88 Ver 2.49: Allowing 100 styles rather than 30.
- Style of FF suppresses display entirely.
- 4 May 88 Ver 2.48: Allows axis labels as high as 10000 before
- switching to scientific notation.
- 23 Mar 88 Ver 2.47: Warns about data points dropped after memory
- is full.
- 4 Mar 88 Ver 2.46: Can display bottom and left axes only.
- 10 Feb 88 Ver 2.45: Automatic abscissas restart with each
- new curve.
- 23 Jan 88 Ver 2.44: Reads parameters from script file.
- 25 Nov 87 Ver 2.42: The linestyle is interpreted as a hex
- number, so the color digit can range from 0 (white)
- through f. Plot area is shrunk if necessary so
- wide grid stays within specified width and height.
- 29 Oct 87 Ver 2.41: Marker color controlled only by the
- second digit of the style number.
- 25 Aug 87 Ver 2.40: Large number of labels permitted, via
- dynamic reallocation (shrinking) of data arrays.
- Saving repeat counts.
- 20 Aug 87 Ver 2.39: Tic marks can be outside graph area. # small
- tic marks is adjustable.
- 17 Aug 87 Ver 2.38: width of grid lines can be specified.
-
- AUTHOR
- Copyright (c) 1985 - 1988 by James R. Van Zandt
- (jrv@mitre-bedford.arpa) 27 Spencer Dr., Nashua NH 03062,
- 603-888-2272. Resale forbidden, copying for personal use
- encouraged. Constructive comments welcome.
-