NAME
gview – interactive graph viewer

SYNOPSIS
gview [ –mp ] [ –l logfile ] [ files ]

DESCRIPTION
Gview reads polygonal lines or a polygonal line drawing from an ASCII input file (which defaults to standard input), and views it interactively, with commands to zoom in and out, perform simple editing operations, and display information about points and polylines. (Multiple input files are allowed if you want to overlay several line drawings.) The editing commands can change the color and thickness of the polylines, delete (or undelete) some of them, and optionally rotate and move them. It is also possible to generate an output file that reflects these changes and is in the same format as the input.

Since the move and rotate commands are undesirable when just viewing a graph, they are only enabled if gview is invoked with the –m option.

The –p option plots only the vertices of the polygons.

Clicking on a polyline with button 1 displays the coordinates and a t value that tells how far along the polyline. (t=0 at the first vertex, t=1 at the first vertex, t=1.5 halfway between the second and third vertices, etc.) The –l option generates a log file that lists all points selected in this manner.

The most important interactive operations are to zoom in by sweeping out a rectangle, or to zoom out so that everything currently being displayed shrinks to fit in the swept–out rectangle. Other options on the button 3 menu are unzoom which restores the coordinate system to the default state where everything fits on the screen, recenter which takes a point and makes it the center of the window, and square up which makes the horizontal and vertical scale factors equal.

To take a graph of a function where some part is almost linear and see how it deviates from a straight line, select two points on this part of the graph (i.e., select one with button 1 and then select the other) and then use the slant command on the button 3 menu. This slants the coordinate system so that the line between the two selected points appears horizontal (but vertical still means positive y). Then the zoom in command can be used to accentuate deviations from horizontal. There is also an unslant command that undoes all of this and goes back to an unslanted coordinate system.

There is a recolor command on button 3 that lets you select a color and change everything to have that color, and a similar command on button 2 that only affects the selected polyline. If the input file uses the Multi(...) feature explained below, either flavor of recolor allows you to type a digit in lieu of selecting a color.

The thick or thin command on button 2 changes the thickness of the selected polyline and there is also an undo command for such edits. Finally, button 3 has commands to read a new input file and display it on top of everything else, restack the drawing order (in case lines of different color are drawn on top of each other), write everything into an output file, or exit the program.

Each polyline in an input or output file is a space–delimited x y coordinate pair on a line by itself, and the polyline is a sequence of such vertices followed by a label. The label could be just a blank line or it could be a string in double quotes, or virtually any text that does not contain spaces and is on a line by itself. The label at the end of the last polyline is optional. It is not legal to have two consecutive labels, since that would denote a zero–vertex polyline and each polyline must have at least one vertex. (One–vertex polylines are useful for scatter plots.) Under the –l option, a newline causes the selected polyline's label to appear in the log file (where it could be seen by invoking tail –f in another window).
If the label after a polyline contains the word Thick or a color name (Red, Pink, Dkred, Orange, Yellow, Dkyellow, Green, Dkgreen, Cyan, Blue, Ltblue, Magenta, Violet, Gray, Black, White), whichever color name comes first will be used to color the polyline. Alternatively, labels can contain Multi followed by single–letter versions of these names: (R, P, r, O, Y, y, G, g, C, B, b, M, V, A, K, W, each optionally preceded by T). Then recolor followed by a nonzero digit n selects the nth alternative for each polyline.

EXAMPLE
To see a graph of the function y=sin(x)/x generate input with an awk script and pipe it into gview:
awk 'BEGIN{for(x=.1;x<500;x+=.1)print x,sin(x)/x}' | gview

SOURCE
/sys/src/cmd/gview.c

SEE ALSO
awk(1), tail(1)

BUGS
The user interface for the slant command is counter–intuitive. Perhaps it would be better to have a scheme for sweeping out a parallelogram.

The –p option makes the interactive point selection feature behave strangely, and is unnecessary since extra blank lines in the input achieve essentially the same effect.

Copyright © 2018 Alcatel-Lucent. All rights reserved.