GSCALE is useful for 1) obtaining nice ticks for plots and 2) ensuring that calculated data (e.g. a normal curve) is on the same scale as a plot or histogram.
Illustrated here is how GSCALE is used to perform 1) for %MARGPLOT. In this example, the obtained tick positions were used for binning data for dotplots, with a check made to ensure that the bins derived from GSCALE contained all the data.
In main body of macro, call subroutine to obtain nice tick positions
#determine scaling of y minimum y yminv maximum y ymaxv call scale yminv ymaxv ysmin ysmax ytickpos
#determine scaling of x minimum x xminv maximum x xmaxv call scale xminv xmaxv xsmin xsmax xtickpos
###################################################### #subroutine scale finds scale information using GSCALE macro scale min max smin smax tickpos mcolumn tickpos mconstant min max tmin tmax smin smax tinc ntick k1 gscale min max; nminimum 5; nmaximum 11; tminimum tmin; tmaximum tmax; nticks ntick; tincrement tinc; sminimum smin; smaximum smax.
#ensure that first and last ticks are outside the data if min lt tmin let ntick=ntick+1 let tickpos(1)=tmin-tinc let smin=tmin-1.05*tinc else let tickpos(1)=tmin endif
if max gt tmax let ntick=ntick+1 let smax=tmax+1.05*tinc endif
do k1=2:ntick let tickpos(k1)=tickpos(k1-1)+tinc enddo endmacro |