# Graph (Unix)

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Graph_(Unix)
> Markdown URL: https://mediated.wiki/source/Graph_(Unix).md
> Source: https://en.wikipedia.org/wiki/Graph_(Unix)
> Source revision: 1275130144
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{Short description|Unix graphing utility}}
{{lowercase}}
{{Infobox software
| name                   = graph
| logo                   = 
| screenshot             = 
| screenshot size        = 
| caption                = 
| author                 = [Douglas McIlroy](/source/Douglas_McIlroy)<br />([AT&T Bell Laboratories](/source/AT%26T_Bell_Laboratories))
| developer              = Various [open-source](/source/open-source_software) and [commercial](/source/commercial_software) developers
| released               = 
| latest release version = 
| latest release date    = 
| operating system       = [Unix](/source/Unix), [Unix-like](/source/Unix-like)
| platform               = [Cross-platform](/source/Cross-platform)
| genre                  = [Command](/source/Command_(computing))
| license                = 
| website                = 
}}
In [Unix](/source/Unix), '''graph''' is a [command-line](/source/command-line_interface) utility used to draw plots from tabular data.

== History ==
The '''graph''' utility, written by [Douglas McIlroy](/source/Douglas_McIlroy), was present in the first version of Unix, and every later version, for instance:

* Unix [Version 7](/source/Version_7_Unix), released in 1979 <ref>
{{cite web
|title=graph
|series=Unix v7 manual pages
|url=https://www.unix.com/man-page/v7/1G/GRAPH/
|access-date=Nov 24, 2018
|year=1979
|publisher=[Bell Labs](/source/Bell_Labs)
}}
</ref>
* SunOS 5.10, the [Solaris](/source/Solaris_(operating_system)) version released in 2005 <ref>
{{cite web
|title=graph
|series=SunOS 5.10 manual pages
|url=https://www.unix.com/man-page/sunos/1/graph/
|access-date=Nov 24, 2018
|year=2005
|publisher=[Sun Microsystems](/source/Sun_Microsystems)
}}
</ref>
Its output is a sequence of commands for the '''plot''' utility, which creates [plot](/source/Plot_(graphics))s using [ASCII graphics](/source/ASCII_graphic).

This design demonstrates the [Unix philosophy](/source/Unix_philosophy): defining the plot ('''graph''') and drawing it ('''plot''') are separate tools, so they can be recombined with other tools. For instance, '''plot''' can be substituted with a different utility, that accepts the same plot commands, but creates the plot in a graphics file format, or sends it to a [plotter](/source/plotter).

Unix v7 also provided device drivers for plotting the results to various graphics devices; <ref>
{{cite book
|title=Computer programs in Seismology: CALPLOT graphics
|editor1-first=Robert B.
|editor1-last=Herrmann
|page=vi
|year=2004
|version=3.30
|url=http://www.eas.slu.edu/eqc/eqc_cps/CPS/CPS330/cps330p.pdf
|access-date=Nov 24, 2018
}}
</ref>
this was announced as ''now standard''.<ref>{{cite news
|title=7th Edition UNIX — Summary
|publisher=Bell Laboratories
|location=Murray Hill, New Jersey 07974
|page=1
|date=September 6, 1978
|url=http://a.papnet.eu/UNIX/v7/files/doc/01_summary.pdf
|access-date=Nov 24, 2018
|archive-date=November 24, 2018
|archive-url=https://web.archive.org/web/20181124220133/http://a.papnet.eu/UNIX/v7/files/doc/01_summary.pdf
|url-status=dead
}}</ref> 

The [GNU plotutils](/source/GNU_Plotutils) package provides a free non-exact reimplementation, available for [Linux](/source/Linux) and many other systems.
It can create plots in various graphics formats.

== Usage ==
In its simplest use, the '''graph''' utility takes a textfile containing pairs of numbers, indicating the points of a line plot.

It outputs the line plot.  Several options can be supplied to modify its behavior.

== Example (Unix) ==
<gallery mode="packed" widths="258" heights="191">
Graph (SunOS 5.10) demo, part 1 of 2 - input and execution.png | Preparing example input and running '''graph''' with '''plot'''
Graph (SunOS 5.10) demo, part 2 of 2 - output.png | The results
</gallery>

These screenshots demonstrate basic operation on SunOS 5.10, on which '''graph''' and '''plot''' come preinstalled.
The example input is from the first example in the GNU plotutils manual.

== Example (GNU plotutils) ==
<gallery mode="packed" widths="258" heights="191">
Graph (Ubuntu 14.04 Linux) demo, part 1 of 2 - input and execution.png | Preparing example input and running '''graph''' in Tektronix mode
Graph (Ubuntu 14.04 Linux) demo, part 2 of 2 - output.png | The results
</gallery>

These screenshots demonstrate the GNU plotutils version of '''graph''' when run in an [xterm](/source/xterm), exploiting xterm's ability to emulate a [Tektronix 4010](/source/Tektronix_4010) plotter.

This demo was run on [Ubuntu](/source/Ubuntu), which makes GNU plotutils available as an optional package; many other Linux distributions and other Unix-like systems do the same.

== References ==
{{Reflist}}

==External links==
{{Wikibooks|Guide to Unix|Commands}}

{{Unix commands}}

Category:Command-line software
Category:Unix software

---
Adapted from the Wikipedia article [Graph (Unix)](https://en.wikipedia.org/wiki/Graph_(Unix)) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Graph_(Unix)?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
