Data visualization with SAS programming

Legend of Reflabels

Reply
N/A
Posts: 0

Legend of Reflabels

Is there any way I can make a legend of reflabels in gplot?

I am basically plotting my data of mean against date. But I have two reflabels, namely:
**Current - Line type =1 ; colour = blue
** Average - Line type =3; colour =red

Is there anyway I can have this 2 lines (current and average) in my legend.

Please help
Really appreciate it. Thanks
SAS Employee
Posts: 977

Re: Legend of Reflabels

One way would be to use annotate...

Annotate the colored line segments (using 'move' and 'draw').
And then annotate the descriptive text (using 'label').
N/A
Posts: 0

Re: Legend of Reflabels

I have already labelled the vref's using the reflabels. But because of the heavy data, its not showing properly. Even after using the function 'frontref'.

Hence the reason why i was wondering if there is a way around where I can make legend which shows outside the graph...
SAS Employee
Posts: 977

Re: Legend of Reflabels

Another way with gplot would be to create some data observations that will "look like" a reference line, such as...


data my_data; set sashelp.class;
current=130;
average=105;
run;

symbol1 value=dot color=black;
symbol2 value=none interpol=line l=1 color=blue;
symbol3 value=none interpol=line l=3 color=red;

legend1 label=none position=(bottom center);

proc gplot data=my_data;
plot weight*height=1 current*height=2 average*height=3 /
overlay legend=legend1;
run;
SAS Super FREQ
Posts: 925

Re: Legend of Reflabels

As an alternative, if you have SAS 9.2, you can use PROC SGPLOT which give you the ability to directly associate reflines with the legend:

[pre]
proc sgplot data=sashelp.class;
scatter x=age y=weight;
refline 90 / legendlabel="ninty pounds" name="a" lineattrs=(color=blue);
refline 100 / legendlabel="one hundred pounds" name="b" lineattrs=(color=red);
keylegend "a" "b";
run;
[/pre]

Hope this helps,
Dan
N/A
Posts: 0

Re: Legend of Reflabels

Thanks to both DanH and Robert Allison

Regards
Ask a Question
Discussion stats
  • 5 replies
  • 233 views
  • 0 likes
  • 3 in conversation