WIPIVERSE

graph (Unix)

In Unix and Unix-like operating systems, graph is a command-line utility used to draw plots from tabular data. It was written by Douglas McIlroy at AT&T Bell Laboratories and has been present in the Unix operating system since its early versions, including Unix Version 7 (1979) and SunOS 5.10 (2005).

Function

The graph utility reads numeric data — typically pairs of numbers representing the points of a line plot — from files named on the command line or from standard input. It then produces a sequence of plotting commands that are fed to the companion plot utility, which renders the plot as ASCII graphics or on an attached graphics device.

This separation of responsibilities is often cited as an example of the Unix philosophy: the task of defining the plot (graph) and the task of drawing it (plot) are handled by separate, composable tools that can be recombined with other utilities. For instance, plot can be replaced with a different program that accepts the same plotting commands but outputs to a graphics file format or device.

Options

graph supports a variety of command-line options to adjust the appearance of the output plot. Historically documented options include settings for axis scaling, margins, spacing, and the ability to transpose the horizontal and vertical axes. The specific set of options has varied across different implementations and versions.

Modern Implementations

A free and widely available reimplementation is provided by the GNU plotutils package. This version is considerably more powerful than the original and can generate plots in various graphics formats (such as PNG, SVG, and PostScript) in addition to the traditional terminal-based output. GNU plotutils is included in many Linux distributions and other Unix-like systems, and it is used in various software projects and academic research contexts.

The historical Unix version of graph also came with device drivers for plotting results to various graphics devices, a capability that was noted as standard in Unix Version 7.

References

  • graph. Unix v7 manual pages. Bell Laboratories. 1979.
  • graph. SunOS 5.10 manual pages. Sun Microsystems. 2005.
  • GNU plotutils documentation and project site.
  • Wikipedia: "Graph (Unix)".
Browse

More topics to explore

    Browse all articles