www.sas.com > SAS UK > In the Know Homepage Search | Contact Us     
SAS UK Newsletter Banner SAS - The power to know(tm)  

How to move the axis to the middle of the graph using the Annotate facility

The Annotate facility enables you to generate a special data set of graphics commands from which you can produce graphics output. This data set is referred to as an Annotate data set. You can use it to generate custom graphics or to enhance graphics output from many SAS/GRAPH procedures.

For documentation on the Annotate Facility please visit the SAS OnlineDoc:
http://support.sas.com/documentation/onlinedoc/index.html
The example code below uses the annotate facility to move the axis to the middle of the graph when using Proc GPLOT.

 

/* Set-up graphics environment */
goptions reset=all cback=white border;

/* Create the sample data set, A */
data a;
input xvar yvar;
cards;
1 10
2 20
4 40
5 60
6 80
9 50
10 30
;
run;

/* Create the annotate data set, ANNO which draws the reference lines */
data anno;
length function $ 8;
retain xsys '2' ysys '3' color 'black' when 'a';
do i= 1 to 10 by .25;
 if i/int(i)=1 then do;
   tickhght=2;
   text=left(put(i,2.));
 end;
 else do;
   tickhght=1;
   text='';
 end;
 function='move'; x=i; y=42; output;
 function='draw'; x=i; y=42-tickhght; output;
 function='label'; x=i; y=45; output;
end;
run;

/* Create the title, axis and symbol definitions */
title1 "How to move the axis into the middle of the graph"; 
axis1 origin=(15,15)pct major=none minor=none length=60pct offset=(2,2) label=none value=none;
axis2 origin=(45,15)pct major=(h=-1) minor=(n=4 h=-.5) length=60pct offset=(2,2);
axis3 origin=(15,15)pct major=none minor=none order=(1 to 10 by 1) length=60 pct offset=(2,2) label=none value=none;
symbol1 i=j v=dot c=blue;

/* Create the graph */
proc gplot data=a;
plot yvar*xvar  / href=5.5 vref=40 vaxis=axis1 haxis=axis3 frame anno=anno;
plot2 yvar*xvar / vaxis=axis2 ;
run;
quit;


	
	

The Power to Know
   Contact Us      Worldwide Sites     Search     Site Map     RSS Feeds     Terms of Use    Privacy Statement   Copyright © 2008 SAS Institute Inc. All Rights Reserved