Drawing Graphs

G7 can make a variety of graphs, which can then be printed, saved into Windows metafiles to be included in documents, or copied to the windows clipboard to be pasted into other applications. Here are the basic graph commands and related subsidiary commands. Detailed explanations follow.

title:

Provides the title for the graph.

subti:

Provides the subtitle.

vaxti:

Provides the vertical axis title.

vaxl:

Puts vertical axis labels inside or outside the rectangle of the graph.

graph:

Graphs up to seven series on one graph with one scale.

mgr:

Multi-scale graph. This is most useful with two series, since the left axis scale will be for the first series and the right axis scale for the second.

sgraph:

Scatter graph. Graphs one series against another.

lgraph:

Graphs variables that are in logarithms, while displaying the y axis in natural units

vrange:

Controls the vertical range of graphs (the y-axis scale).

hrange:

Controls the horizontal range for scatter graphs or the right-vertical range for multi-scale graphs.

legend:

Controls printing of legend on graphs.

The characteristics of each line on the graph are set by selecting Graph|Settings from the main menu.

Graph Titles

(ti)tle <title of graph or regression>

Provides a main title that appears on subsequents graphs. Use ti with no following text string to remove the title. Note that the font for the title, subtitle, and other text may be set in the G7 Graph | Font menu.

(subt)itle <text string>

Provides a subtitle on the subsequent graphs. Use subti with no following text string to remove the subtitle.

(vaxt)itle <text string>

Provides a vertically printed title for the y (left) axis. Use vaxti with no following text to remove the left axis title.

vaxl <in | out>

Causes the vertical axes numbers to be printed inside or outside the axes. The default is “vaxl in”.

Displaying Graphs

(gr)aph <name1> [<name2>] [<name3>] … [<name7>] <date1> <date2> [date3]
(gr)aph (<name1>) [(<name2>)] [(<name3>)] … [(<name7>)] <date1> <date2> [date3]
Constructs a standard Line Graph. Graph the named series from <date1> to <date2> or <date3>, if present. If <date3> is present, a vertical line (to separate history from forecast) will appear at <date2>. If dates have not changed since the last graph command, they need not be repeated. After a regression, the actual and predicted values may be plotted by gr *. The actual data will be marked by squares and the predicted by plusses, unless the marks have been changed by a previous line command. Algebraic expressions may be provided in place of some or all of the series names, so long as the expressions are enclosed in parentheses.

Example:

title RTB -- The Treasury Bill Rate
gr rtb 70.1 85.1
(mg)raph <name1> [<name2>] [<name3>] … [<name7>] <date1> <date2> [date3]
(mg)raph (<name1>) [(<name2>)] [(<name3>)] … [(<name7>)] <date1> <date2> [date3]
Consruct a Multi-scale Graph. This is exactly like the graph command except that the series has its own vertical scale chosen so that its graph extends from the top to the bottom of the screen. The scale shown on the left is for the first series; the scale shown on the right is for the second. Algebraic expressions may be provided in place of some or all of the series names, so long as the expressions are enclosed in parentheses.
(lgr)aph <name1> [<name2>] [<name3>] … [<name7>] <date1> <date2> [date3]
(lgr)aph (<name1>) [(<name2>)] [(<name3>)] … [(<name7>)] <date1> <date2> [date3]
Construct a Semi-Logarithmic Graph. This is exactly like the graph command except that the series are expected to be in logarithms. The vertical scale will be marked in the natural units, not the units of the logarithms. If vertical range control is in effect (see below), the vertical ranges will be presumed to be in natural units. Algebraic expressions may be provided in place of some or all of the series names, so long as the expressions are enclosed in parentheses.
(sgr)aph <series 1> <series 2>
(sgr)aph (<series 1>) (<series 2>)
Construct a Scatter Graph. This will display a scatter diagram of <series 1> and <series 2>. The graph is created with <line 1> characteristics. Use the “0 width” option on the line command to plot only scatter points; otherwise the points will be connected. Each point on the two-dimensional graph measures the value of the first variable on the vertical axis, and the value of the second variable on the horizontal axis. For use only with the sgraph command, there is an hrange command that works just like the vrange command but it controls the horizontal axis. Algebraic expressions may be provided in place of either or both of the series names, so long as the expressions are enclosed in parentheses.

Style of Graph – Line, Range, Legend Control

line <number> <color> <width> <style> <mark> <fill> <left> <right>

The easy way to use the line command is interactively. Use Graph | Settings from the main menu. For use in command files, however, the following reference information is provided. The options are:

Number:

The line number – 0 for the frame and annotation, 1-4 for the series graphed

Color:

The following colors are available when graphing in G7 – black, maroon, green, olive, navy, purple, teal, gray, red, lime, yellow, blue, fuchsia, aqua, ltgray, dkgray, white, lavender, brown, sienna, orange, tomato, coral, hotpink, azure, skyblue, gold, dkred, blood, ltred, dkblue, ltblue, dkgreen, ltgreen, seagreen, chartreuse, midnight, chocolate, slategray, forest, turquoise, and pumpkin. Alternatively, the user can enter a numbered color code from 1 to 63 for EGA and VGA monitors.

Width:

The width of the line in pixels – 0 for no line (only marks or bars are printed). With a width above 1, all lines will be solid.

Mark:

Point markers – + for plus signs, x for x’s, s for squares, d for diamonds, ^ for up-pointing triangles, v for down pointing triangles, > for arrows in direction of line, b for bars, f for bars without a rectangle around them. (Use f with 0 fill for the “low” line in “high-low” graphs.)

Style:

The line style – 0 for a solid line, 1 for a dashed line, 2 for a dotted line, 3 for a dashed line, 4 for dash dot, 5 for dash dot dot, 6 for none.

Fill:

Fill pattern for bars: 0 for Solid, 1 for Clear, 2 horizontal hatching, 3 for vertical hatching, 4 for forward diagonal, 5 for backward diagonal, 6 for cross hatching, and 7 for diagonal cross hatching.

Left:

Right:

These values (between 0 and 1) specify where the left and right edges of the bar fall in the available space for each observation. The first value (left) must be smaller than the second value (right). Entering values of 0.2 and 0.8 for left and right, respectively, would yield a bar that started 20% across the column and end at 80%. Parallel bars are drawn by assigning non-overlapping intervals to different series. Stacked bars or high-low graphs are produced with overlapping intervals.

Vertical Range Control

(vr)ange <bottom> [top]
vr <bottom> [<line1> [<line2> [… [<line8>]]]] <top>
vr off
The graphing program normally sets the vertical range so the series extend from the bottom to the top of the graph. Sometimes, it is desirable to set the range independently. This is done with the (vr)ange command. For example “vr 0 100” will make all subsequent graphs have 0 at the bottom and 100 at the top until the “vr off” command is encountered, restoring G7 to its normal mode. If the <top> is omitted, then only the bottom of the graph is set and the program finds the top so that the graph fits on the screen.

If one or more of the optional <line> entries are present, horizontal lines will be marked at those levels. The lighted pixels which mark these lines are located above the long marks on the horizontal axis, so theyalso serve as meaningful vertical lines.

Legend Control

(le)gend <a> [b]

Controls printing a legend at the bottom of a graph. ‘a’ equals

y:

for yes, prints the legend (default)

n:

for no, do not print the legend

s:

leave space for legend but do not print. Useful for allowing the user to annotate the legend.

y:

for yes, mark the dates (default)

n:

for no, do not mark dates. Useful for making bar graphs of data occurring at arbitrary intervals.

Background color

color <background>

The background color can be set interactively with Graph | Settings menu item or by the following .

Example:

color 4

Sets colors for graphs. The numbers may range from 0 to 7.

Graphing Distributed Lags For graphing distributed lags, it is helpful to specify the “dates” as coefficient numbers. Thus, to plot the coefficients a3 through a16 do “gr rcoef :3 16”. The “:” is the signal to take the following numbers as regression coefficient numbers.

Setting Dates Without Actually Graphing

gdates <date1> <date2> [date3]

Sets the dates used by subsequent graph commands. With two dates provided, the series will be graphed from <date1> to <date2>. If a third date is given, the series will be graphed from <date1> to <date3>, with a vertical line drawn at <date2>.

gdates a

Selects “automatic” dates for graph commands. The automatic dates are the first and last date of the series actually present. The default setting in look is for automatic dates, unless specific dates have been previously specified. Automatic dates also adjust automatically to the frequency of the series. Not to be trusted when more than one series is being placed on the same graph.

Printing and Saving Graphs

gprint

This command prints the current graph to the printer. It is equivalent to picking Graph | Print from the main menu.

autoprint < y | n>

This command turns the autoprint flag on or off. It is off by default. When autoprint is set to ‘y’, then every graph that is displayed also is printed automatically.

gsave <filename>

This command is equivalent to picking Graph | Save from the main menu. It will create a Windows Metafile with the name given, followed by a .WMF extension. Do not supply the file extension on the command line.

Annotating Graphs The following commands allow text and arrows to be drawn on a graph using G7 commands. Alternatively, the Graph | Annotation utility may be used to add these features interactively to a graph.

anntext <x-coordinate> <y-coordinate> <text to be inserted>

This command adds text to a graph. The x and y are values 0.000 to 1.000. The ‘x’ values start from the left side, where 0.250 would be 1/4 of the way from the left. The ‘y’ values start from the top of the graph, where 0.25 would be 1/4 of the way down from the top.

Example:

anntext 0.549 0.128 Hurricane Katrina
annline <starting x-coordinate> <starting y-coordinate> <ending x-coordinate> <ending y-coordinate> <symbol>

This command adds an arrow to a graph. ‘x’ and ‘y’ are values 0.000 to 1.000. The ‘x’ values start from the left side, where 0.250 would be 1/4 of the way from the left. The ‘y’ values start from the top of the graph, where 0.25 would be 1/4 of the way down from the top. <symbol> is a character added to the end of the line. Typically, the symbol is the ‘>’ character that forms an arrow point.

Example:

annline  0.260  0.145  0.63  0.79 >
zip [off]

After the “zip” command has been given, the program will not pause after a graph has been created. It also does not calculate the “lever” variable after each regression. It particularly is useful for rapid re-estimation of an entire model when data has been updated. The command to turn off zip is “zip off”.

Use of the Group Titles Feature It often is the case that you know the sector number of a series and you need to know the corresponding title. This is where the group titles features comes in handy. There are two commands that work together, gtfile and gtitle.

gtfile < titles file | “off” >

This command scans the specified titles file and stores the starting position of each line in the file. This makes it possible to use the gtitles command to supply a title from the titles file when given a number. To close the titles file or to load an alternative titles file, issue the command “gtitle off”.

Example titles file:

1 "Agriculture, forestry, and fisheries"
2 "Metal mining"
3 "Coal mining"
4 "Natural gas extraction"
5 "Crude petroleum"
6 "Non-metallic mining"
gtitle <number>

Use of this command requires that a gtfile command has been given with a valid titles file as an an argument. The gtitle command then will use the n’th line of the titles file to put a title in the following graph command. These commands particularly are handy in combination with the do command or with an add file with group arguments. Since in many cases only sector numbers are being passed to such add files, the gtitle command allows you to specify only a sector number but still find the appropriate title for that sector.