RATS 10.1
RATS 10.1

Graphics /

Adding Text to Graphs (GRTEXT)

Home Page

← Previous Next →

The GRTEXT command allows you to add text anywhere inside a graph image or in the margins of the graph, with options allowing you to specify the position of the text, the alignment, and the font style. To use GRTEXT, you need to enclose the graphing and GRTEXT command(s) inside an SPGRAPH block (even if you are only doing one graph).

 

The code excerpt below is from the source file for the @REGCORRS procedure which generates residual autocorrelation plots. We use GRTEXT to (optionally) include the Q statistics for residual autocorrelation and the information criteria for the model. This uses the ENTRY and Y options to place the information towards the bottom left of the graph. Because the graph is specified to have a minimum value of -1, we know that Y values of -.8 and -.9 will be in that corner.

 

disp(store=qstring) "Q=" *.## %cdstat "P-value" #.##### %signif

disp(store=cstring) "AIC=" *.### %aic "SBC=" *.### %sbc

inquire(series=corrs) * ncorr

 

if graph {

   set upper 1 ncorr =  2.0/sqrt(%nobs)

   set lower 1 ncorr = -2.0/sqrt(%nobs)

   *

   * We use SPGRAPH as a wrapper because we might be using GRTEXT to add

   * the final Q and the criteria to the graph.

   *

   spgraph(window=ltitle)

   graph(max=1.0,min=-1.0,number=1,style=bargraph,$

      overlay=line,header=header,footer=footer,ovcount=2,ovsame) 3

   # corrs 2 ncorr

   # upper 2 ncorr 1

   # lower 2 ncorr 1

   if qstats

      grtext(entry=2,y=-.9,align=left,size=16) qstring

   if criteria

      grtext(entry=2,y=-.8,align=left,size=16) cstring

   spgraph(done)

}

 


Copyright © 2025 Thomas A. Doan