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
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.