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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.