xgraph - Draw a graph on an X11 Display
xgraph [ options ] [ =WxH+X+Y ] [ -display host:display.screen ] [ file
The xgraph program draws a graph on an X display given data read from
either data files or from standard input if no files are specified.
It can display up to 64 independent data sets using different colors
and/or line styles for each set. It annotates the graph with a title,
axis labels, grid lines or tick marks, grid labels, and a legend.
There are options to control the appearance of most components of the
The input format is similar to graph(1G) but differs slightly. The
data consists of a number of data sets. Data sets are separated by a
blank line. A new data set is also assumed at the start of each input
file. A data set consists of an ordered list of points of the form "X
Y". Each point must appear on a separate line. The name of a data set
can be specified by a line which begins with a double quote followed
by the set name. An example input file with three data sets is shown
below (note set three is not named):
After xgraph has read the data, it will create a new window to
graphically display the data. The interface used to specify the size
and location of this window depends on the window manager currently in
use. Refer to the reference manual of the window manager for details.
Once the window has been opened, all of the data sets will be
displayed graphically (subject to the options explained below) with a
legend in the upper right corner of the screen. To zoom in on a
portion of the graph, depress a mouse button in the window and sweep
out a region. xgraph will then open a new window looking at just that
portion of the graph. xgraph also presents two control buttons in the
upper left corner of each window: Close and Hardcopy. Windows are
closed by depressing a mouse button while the mouse cursor is inside
the Close button. Typing EOF (control-D) in a window also closes that
window. Depressing a mouse button while the mouse cursor is in the
Harcopy button causes a dialog to appear asking about hardcopy
(printout) options. These options are described below:
Specifies the type of the output device (e.g. "HPGL",
"Postscript", etc). An output device is chosen by depressing the
mouse inside its name. The default values of other fields will
change when you select a different output device.
Specifies whether the output should go directly to a device or to
a file. Again, the default values of other fields will change
when you select a different disposition.
File or Device Name
If the disposition is "To Device", this field specifies the
device name. A device name is the same as the name given for the
-P command of lpr(1). If the disposition is "To File", this
field specifies the name of the output file.
This specifies the maximum size of the plot on the hardcopy
device in centimeters. xgraph takes in account the aspect ratio
of the plot on the screen and will scale the plot so that the
longer side of the plot is no more than the value of this
parameter. If the device supports it, the plot may also be
rotated on the page based on the value of the maximum dimension.
Title Font Family
This field specifies the name of a font to use when drawing the
graph title. Suitable defaults are initially chosen for any given
hardcopy device. The value of this field is hardware specific --
refer to the device reference manual for details.
Title Font Size
This field specifies the desired size of the title fonts in
points (1/72 of an inch). If the device supports scalable fonts,
the font will be scaled to this size.
Axis Font Family and Axis Font Size
These fields are like Title Font Family and Title Font Size
except they specify values for the font xgraph uses to draw axis
labels, and legend descriptions.
After specifing the parameters for the plot, the "Ok" button
causes xgraph to produce a hardcopy. Pressing the "Cancel"
button will abort the hardcopy operation.
xgraph accepts a large number of options most of which can be
specified either on the command line or in the user's ~/.Xdefaults
file. A list of these options is given below. The command line option
is specified first with its X default name (if any) in parenthesis
afterward. The format of the option in the X defaults file is
"program.option: value" where program is the program name (xgraph) and
the option name is the one specified below. Note that the value of a
flag in the X defaults file must be "1".
These options specify the data set name for the corresponding
data set. The digit should be in the range '0' to '63'. This
name will be used in the legend.
-b Force xgraph to output the graph in black and white (even if the
display is color). This is useful for those using _x_w_d(_1) to
produce hardcopies of the graph.
-bar Specifies that vertical bars should be drawn from the data points
to a base point which can be specified with -brb. Usually, the
-nl flag is used with this option. The point itself is located
at the center of the bar.
Draw a bounding box around the data region. This is very useful
if you prefer to see tick marks rather than grid lines (see -tk).
-bd <color> (Border)
This specifies the border color of the xgraph window.
-bg <color> (Background)
Background color of the xgraph window.
This specifies the base for a bar graph. By default, the base is
This specifies the width of bars in a bar graph. The amount is
specified in the user's units. By default, a bar one pixel wide
-bw <size> (BorderSize)
Border width (in pixels) of the xgraph window.
-fg <color> (Foreground)
Foreground color. This color is used to draw all text and the
normal grid lines in the window.
-lf <fontname> (LabelFont)
Label font. All axis labels and grid labels are draw using this
font. It must be a fixed-width font.
-lnx Specifies a logarithmic X axis. Grid labels represent powers of
-lny Specifies a logarithmic Y axis. Grid labels represent powers of
Specifies the width of the data lines in pixels. The default is
This option limits the range of the X axis to the specified
interval. This (along with -ly) can be used to "zoom in" on a
particularly interesting portion of a larger graph.
This option limits the range of the Y axis to the specified
Mark each data point with a distinctive marker. There are eight
distinctive markers used by xgraph. These markers are assigned
uniquely to each different line style on black and white machines
and varies with each color on color machines.
Similar to -m but markers are assigned uniquely to each eight
consecutive data sets (this corresponds to each different line
style on color machines).
Turn off drawing lines. When used with -m, this can be used to
produce scatter plots. When used with -bar, it can be used to
produce standard bar graphs.
Marks each data point with a small marker (pixel sized). This is
usually used with the -nl option for scatter plots.
Similar to -p but marks each pixel with a large dot.
Reverse video. On black and white displays, this will invert the
foreground and background colors. It does nothing on color
This option specifies the lines should be drawn as spline curves.
Currently, this is implemented using the X spline option which
fits only three points at a time. Thus, the effect is not what
you might expect.
Title of the plot. This string is centered at the top of the
Subtitle of the plot. This string is centered at the bottom of
-tf <fontname> (TitleFont)
Title font. This is the name of the font to use for the graph
title. It defaults to 9x15.
This option causes xgraph to draw tick marks rather than full
grid lines. The -bb option is also useful when viewing graphs
with tick marks only.
This is the unit name for the X axis. Its default is "X".
This is the unit name for the Y axis. Its default is "Y".
-zg <color> (ZeroColor)
This is the color used to draw the zero grid line.
Some options can only be specified in the X defaults file. These
options are described below:
Specifies the color for a data set. Eight independent colors can
be specified. Thus, the digit should be between '0' and '7'. If
there are more than eight data sets, the colors will repeat but
with a new line style (see below).
Specifies the line style for a data set. A sixteen-bit integer
specifies the sixteen-bit pattern used for the line style. Eight
independent line styles can be specified. Thus, the digit should
be between '0' and '7'. If there are more than eight data sets,
these styles will be reused. On color workstations, one line
style is used for each of eight colors. Thus, 64 unique data
sets can be displayed.
Width, in pixels, of normal grid lines.
Line style pattern of normal grid lines.
Width, in pixels, of the zero grid line.
Line style pattern of the zero grid line.
A test program for xgraph is included. Try the following command to
check out xgraph:
xgtest 7 -5.0 5.0 0.1 | xgraph
This should produce a graph with a series of parabolic curves.
David Harrison University of California
Modified by Ivica Crnkovic, ABB Automation AB, Sweden