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
Example:
title RTB -- The Treasury Bill Rate gr rtb 70.1 85.1
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
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.