Sample 24837: Labeling plot lines in an overlay plot
/**************************************************/
/* The Annotate facility is used to label */
/* individual plot lines created with PROC GPLOT. */
/**************************************************/
/* Set graphics options */
goptions reset=all gunit=pct cback=white
colors=(black) border ftext=zapf htext=3;
/* Create input data set, PRODCOST */
data prodcost (drop=tcprev tfc tvc tc);
retain tcprev 0;
input quan tfc tvc;
tc=tfc+tvc;
afc=tfc/quan; /* average fixed cost */
avc=tvc/quan; /* average variable cost */
atc=tc/quan; /* average total cost */
mc=tc-tcprev; /* marginal cost */
tcprev=tc;
datalines;
1 10 05
2 10 08
3 10 10
4 10 11
5 10 13
6 10 16
7 10 20
8 10 25
9 10 31
10 10 38
11 10 46
;
/* Create the Annotate data set, LINETEXT */
data linetext(drop=afc atc avc mc quan);
length function color $ 8 text $ 20;
retain function 'label' xsys ysys '2' hsys '3' position '6' /* Plot variable values position the labels */
style 'swiss' size 3; /* so, XSYS and YSYS use coordinate system 2, */
/* absolute data values. */
set prodcost end=last;
if last then
do;
x=quan;
y=mc; text=' Marginal Cost'; color='red'; output;
y=atc; text=' Avg. Total Cost'; color='vig'; output;
y=afc; text=' Avg. Fixed Cost'; color='blue'; output;
y=avc; text=' Avg. Var. Cost'; color='orange'; output;
end;
run;
/* Add the title and footnotes */
title1 height=6 'Projected Cost of Production';
footnote1 font=swissl justify=left height=2.5 ' SAS/GRAPH' move=(+0,+.5) '02'x
move=(+0,-.5) ' Software' justify=right 'COSTS ';
footnote2 height=2 angle=90 ' ';
/* Create axis definitions */
axis1 minor=none value=(font=swiss) offset=(1,22)
label=('Thousands of Units') width=3;
axis2 order=(0 to 16 by 2) minor=none value=(font=swiss) offset=(0,0)
label=('Dollar Cost' justify=right '(in hundreds)') width=3;
/* Choose the interpolation method and assign symbol characteristics */
symbol1 interpol=spline width=4 color=red;
symbol2 interpol=spline width=4 color=vig line=2;
symbol3 interpol=spline width=4 color=blue line=10;
symbol4 interpol=spline width=4 color=orange line=20;
/* Produce the plot */
proc gplot data=prodcost;
plot (mc atc afc avc)*quan / overlay frame haxis=axis1 vaxis=axis2
annotate=linetext;
run;
quit;

The Annotate facility is used to label individual plot lines created with PROC GPLOT.
| Type: | Sample |
| Topic: | SAS Reference ==> Procedures ==> GPLOT Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Elements ==> Labels
|
| Date Modified: | 2007-10-15 07:31:19 |
| Date Created: | 2004-10-15 11:01:03 |
Operating System and Release Information
| SAS System | SAS/GRAPH | All | n/a | n/a |