Graphics / Multiple Graphs on Page (SPGRAPH) |
You can put two or more individual graphs on a single picture using SPGRAPH with the HFIELDS (horizontal fields) and VFIELDS (vertical fields) options. For example:
spgraph(vfields=2,hfields=2)
some combination of four GRAPH, SCATTER, GCONTOUR or GBOX instructions
spgraph(done)
This SPGRAPH divides the available space in half in each direction, creating four zones of equal size. The graphs (by default) fill the zones by rows beginning at the top left. Note, however, that the characters on the small graphs are sized to be proportional to what they would be on a full page; that is, each quarter graph will look like a reduced version of the same graph done by itself. The labeling (particularly on the scales) can sometimes get too small to be readable, particularly if you get to four or more graphs in either direction. Depending upon the situation, you may want to increase the character sizes using GRPARM, or you might want to suppress the axis labeling altogether. To do this, use NOTICKS and SCALE=NONE on GRAPH and VSCALE=NONE and HSCALE=NONE on SCATTER or GCONTOUR.
You also need to be careful that you do not leave false impressions by allowing each graph to find its own range. This could inflate the appearance of what may be, in reality, some very small effects. Most of the work in doing a matrix of graphs is, in fact, just preparation.
The following (from example SPGRAPH.RPF) graphs the exchange rate of the dollar versus four foreign currencies. These were first given a common reference by converting them to percentage appreciation of dollars per foreign unit since the start of the sample. We then used TABLE to get the maximum and minimum values attained across all the countries, and use these as the MAX and MIN on each GRAPH. This ensures that the very modest movements relative to the Canadian dollar aren’t exaggerated relative to the much larger movement versus the yen.
We generally slightly indent the lines between the SPGRAPH and the corresponding SPGRAPH(DONE) to make it easier to follow what is happening.
spgraph(vfields=2,hfields=2,header="U.S. Dollar vs Major Currencies",$)
subheader="Percent appreciation over the sample")
dofor i = canusxsr frausxsr jpnusxsr gbrusxsr
graph(max=%maximum,min=%minimum,header=NiceLabels(%l(i)))
# i
end dofor
spgraph(done)
Here is another example. This is taken from an example in Diebold (2004). This is example DIEB3P235.RPF from the textbook examples. Note that this does a mix of SCATTER and GRAPH instructions.
spgraph(hfields=2,vfields=2,footer="Figure 9.17 Recursive Analysis: Breaking Parameter Model")
scatter
# x y3
rls(cohist=cohist,sehist=sehist,sighist=sighist,csum=cusum) y3 / resids
# x
set upperco = cohist(1)+sehist(1)*2.0
set lowerco = cohist(1)-sehist(1)*2.0
graph(header="Recursive Estimates") 3
# cohist(1)
# upperco 10 * 2
# lowerco 10 * 2
set upperres = 2.0*sighist
set lowerres = -2.0*sighist
graph(header="Recursive Residuals") 3
# resids
# upperres / 2
# lowerres / 2
set cusum = cusum/sqrt(%seesq)
set upper5 startr end = .948*sqrt(%ndf)*(1+2.0*(t-startr)/%ndf)
set lower5 startr end = -upper5
graph(header="CUSUM test") 3
# cusum
# upper5 / 2
# lower5 / 2
spgraph(done)
Copyright © 2025 Thomas A. Doan