Hi, I'm creating a plot where i want to label a point.
The following program creates data and creates the plot
data t; do i=0 to 60 by 1; month=intnx('month','01nov2017'd,i,'b'); v= rand('normal'); if i = 20 then do; v2=v; label='I want a text label.............................'; end; else do; v2 = .; label=''; end; output; end; format month date9.; run; proc sgplot data=t; scatter x=month y=v; text x=month y=v2 text=label/ position=topright; xaxis display=(nolabel) grid interval=month; run;
When running the program as above the following appears
There is large unused space to he right.
If I run the program with topleft instead I get large unused space to the left instead.
Running with the position = Center
I get unused space both left and right.
My question is:
Are there any option(s) where I can avoid the large unused space?
If not is this a bug. It seems strange that the system set aside space that only will be used when the labels are at the end and is completely unnecessary when the labels are in the middle of the plot?
Thanks
Look at the CONTRIBUTEOFFSETS option on the TEXT plot. For your case, the best option is:
contributeoffsets = (ymin ymax)
That way, the text will not get clipped off along the top or bottom of your graph, but you will not get the extra space along the sides. Of, you can do:
contributeoffsets = none
since your labels are in the middle of your graph.
Hope this helps!
Dan
Look at the CONTRIBUTEOFFSETS option on the TEXT plot. For your case, the best option is:
contributeoffsets = (ymin ymax)
That way, the text will not get clipped off along the top or bottom of your graph, but you will not get the extra space along the sides. Of, you can do:
contributeoffsets = none
since your labels are in the middle of your graph.
Hope this helps!
Dan
Thanks a lot worked like a dream.
Pål N
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.