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.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: