BookmarkSubscribeRSS Feed
xizidememeda
Calcite | Level 5

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!

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

Give us data to plot.

Use one the SASHELP tables.

ballardw
Super User

@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.

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 685 views
  • 0 likes
  • 3 in conversation