Setting Graph Styles

While it is very simple to get a quick graph in G7, it also is possible to refine the graph. In order to produce nice looking reports, it is worth digressing from model building for a moment to learn what sorts of graphs you can make.

The dates over which series are graphed is controlled by the gdates command . This command may be followed by two or three dates, for example:

gdates 1980.1 2010.1
gdates 1980.1 2010.1 2012.2

Graphs drawn following the first of these commands will cover the period 1980.1 – 2010.1. Graphs drawn following the second cover the same period but have a vertical line following 2010.1. This vertical line is useful, for example, to divide history from forecast or the period over which a regression was fit from the period over which it was tested. Exception: graphs drawn with the gr * command use dates set by the limits command for the previous regression. For greater variety in your graphs, choose Graph | Settings on the main menu. You will get a window for setting the characteristics of up to seven lines on the graphs. You can select the color, width (in pixels), style (solid, dotted, dashed, dash dot, and dash dot dot – these work only for lines 1 pixel wide), mark, fill, and left and right parameters. The last three apply only if the type “bar” is chosen for the mark. The fill has to do with what sort of hatching appears in bars. The left and right parameters, numbers between 0 and 1, show where, within the space allocated for the bar, the left and right edges of the bar should go. For example, with left = 0.1 and right = 0.9, the bar will be in the center of the allowed space, and the bars will be four times as wide (0.8 units) as the space between them (0.2 units). To eliminate the line connecting points marked by bars, set its width to zero. Experiment with what you can do with these options. If you wish to save your graph settings for a future run of G7, click the “Save to file” button at the bottom of the screen. You will be asked for a filename. Any valid file name is acceptable, but let us suppose you say GRAPHS.SET. Then the next time you start G7 you can give the command “add GRAPHS.SET” and have your settings back. You even can add at the bottom of the G.CFG file the line

Initial command; add GRAPHS.SET

and you automatically will have back your settings.

Normally, G7 will adjust the vertical scale automatically to include all points on any series that will be graphed, but only the top, bottom, and middle of the vertical scale are labeled. You can, however, control the vertical range vertical range of the graph with the vrange (or vr) command. For example,

vr 0 500 1000 1500 2000

will cause graphs to be drawn with a range from 0 to 2000 and horizontal lines at 0, 500, 1000, 1500, and 2000. These lines will be labeled. The default behavior is to put the labels inside the box of the graph, but you can put them outside by first giving the vertical axis label command, vaxl. It can be

vaxl out

to put them outside of the frame of the graph or

vaxl in

to put them inside the frame. The vr command continues in force until another vr command is given. To simply turn it off and go back to the default, use

vr off

One particularly useful form of the vr command is

vr 0

which sets the lower boundary of the following graphs to be 0, while the top is picked by the program to fit in the highest point in any series. Try graphing gdpR with careful vertical axis labeling done with the vr and vaxl commands.

In addition to the title command, which we have used frequently, there is the subtitle command, which can be abbreviated as subti, that provides a subtitle for the graph. The legend command controls whether or not the legend normally at the bottom of the graph will be included or not. The format is “legend yes” or “legend no”. Try using the subtitle and legend commands.

Besides the ordinary gr command, there are three other variants of it. The mgr or multi-graph command chooses a separate scale for each series graphed. For example, you may want to put the Treasury bill rate, rtb, and Residential construction, vfrR, on the same graph, but they have totally different scales. The answer is to make the graph with mgr; for example,

mgr rtb vfrR

Semi-logarithmic graphs are popular because series growing at a constant percent per year appear as straight lines. It is, however, often desirable to label the vertical axis in the original units. This is done by the lgr command. For example, to graph the Standard and Poor’s composite index of 500 stocks from 1980.1 to 2010.2, we could do

f lsp500 = @log(sp500)
vr 100 200 400 800 1600 3200 4800
gdates 1980.1 2010.2
lgr lsp500

Do it and note the straightness of the line and the labeling of the vertical axis in the original units.

Finally, for graphs in which the horizontal axis is not time but some other variable, use the sgr or scatter graph command.