Hi all!
I use the following code to plot a graph, however, I find that I cannot change the position of the legend. Is it because I changed the default size of the graph? I tried many times, but the legend position didn't change.
ods graphics on / width=12in;
ods graphics on / height=7in;
proc sgplot data=hor;
keylegend / location=inside position=bottomleft;
xaxis values=(1 2 3 4 5) label='portfolios';
yaxis label='betas';
y2axis label="gamma";
highlow x=n high=MH low=ML;
scatter x=n y=e / datalabel;
scatter x=n y=r / datalabel y2axis;
run;
I appreciate it very much for your warm help!
@xizidememeda wrote:
Hi all!
I use the following code to plot a graph, however, I find that I cannot change the position of the legend. Is it because I changed the default size of the graph? I tried many times, but the legend position didn't change.
ods graphics on / width=12in; ods graphics on / height=7in; proc sgplot data=hor; keylegend / location=inside position=bottomleft; xaxis values=(1 2 3 4 5) label='portfolios'; yaxis label='betas'; y2axis label="gamma"; highlow x=n high=MH low=ML; scatter x=n y=e / datalabel; scatter x=n y=r / datalabel y2axis; run;
I appreciate it very much for your warm help!
Where does your legend appear?
If you specify a location that has lots of your plot values the legend is shifted to reduce collisions.
From the documentation:
If LOCATION=INSIDE is specified, the legend is automatically positioned near an edge of the plot area that has the least amount of collision with the data.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.