LinuxCommandLibrary

grap

Search files for specific patterns

TLDR

Process a grap file and save the output file for future processing with pic and groff

$ grap [path/to/input.grap] > [path/to/output.pic]
copy

Typeset a grap file to PDF using the [me] macro package, saving the output to a file
$ grap [path/to/input.grap] | pic -T [pdf] | groff -[me] -T [pdf] > [path/to/output.pdf]
copy

SYNOPSIS

grap [option...] [file...] | pic | troff

PARAMETERS

-a num
    Set aspect ratio (height/width)

-b
    Draw baseline at bottom

-c
    Center graph horizontally

-e
    Expand graph to fill frame

-f
    Draw frame around graph

-g
    Draw grid lines

-i
    Place labels inside frame

-j
    Justify labels

-k
    Keep graph together (no page break)

-l text
    Specify label

-m num
    Set maximum size

-n
    No axis lines

-o
    Overlap plots

-p
    Plot points only

-r
    Reverse plot direction

-s x y
    Set size

-t
    Draw axis ticks

-u
    Labels up

-v x y
    Set viewport

-w x0 x1 y0 y1
    Set world coordinates

-x num
    X reference line

-y num
    Y reference line

DESCRIPTION

grap is a historical Unix command that preprocesses a simple graph description language into pic macros for rendering by troff. Designed for creating publication-quality line graphs, bar charts, and scatter plots, it excels in technical documentation from the pre-GUI era. Users specify data points, axes, labels, and styles in a declarative input format, which grap translates into vector graphics primitives.

Key strengths include flexible scaling, automatic labeling, grid lines, and multiple plot overlays on one page. It supports world coordinates for precise positioning and handles legends, error bars, and spline curves. Output integrates seamlessly with troff pipelines for PostScript or other formats via dpost.

Though superseded by modern tools like gnuplot or matplotlib, grap remains valuable for legacy typesetting, minimal environments, or learning early Unix graphics. Input files use commands like .G1 to start graphs, followed by data and options, ending with .GE. Its simplicity suits batch processing in man pages and papers.

CAVEATS

Deprecated; not installed by default on modern systems. Requires pic and troff. Limited to 2D line/bar graphs; no interactive use or color support.

INPUT EXAMPLE

.G1 -g -l "My Graph"
size 5 3
data y 1 2 3 4
.GE

HISTORY

Developed by Jon Bentley at Bell Labs (~1979) for AT&T documentation. Part of early Unix 7th Edition tools; evolved with BSD and System V. Last significant updates in 1980s; now legacy.

SEE ALSO

pic(1), troff(1), tbl(1), eqn(1)

Copied to clipboard