Reputation: 11
I am plotting in SAS using SGPLOT. I added a few reflines on the x-axis to mark certain dates however, the labels of these reflines become vertical as shown here. With only three reflines, the labels were horizontal as I hoped. However, as I added more reflines, the labels turned vertical.
Is there a way to change the orientation of the label? Or is it just because there is not enough space...
Here is my code for the refline:
refline '01Jul2002'd / axis=x label = "[1]"
labelloc=outside labelpos=max labelattrs=(size=6.5pt family="arial")
Upvotes: 1
Views: 2469
Reputation: 63424
SAS is automatically rotating them in an attempt to "fit" them (or to indicate they're overlapping visually), more than likely. Using Reeza's example, this is trivial to reproduce.
proc sgplot data=sashelp.stocks(where=(stock='IBM'));
series x=date y=open;
refline '01Jul2002'd / axis=x label = "[1]"
labelloc=outside labelpos=max labelattrs=(size=6.5pt family="arial");
refline '02Jul2002'd / axis=x label = "[2]"
labelloc=outside labelpos=max labelattrs=(size=6.5pt family="arial");
run;
With just one, it is horizontal, but the second one causes a rotation.
I don't see a way to fix this other than having fewer reference lines so that the labels don't try to overlap. Neither SGPLOT nor GTL seems to give an option (usually named FITPOLICY) for reference line plots. You could use a different kind of plot I suppose which might give you more options, or use annotation rather than reference lines (it's possible to duplicate reference lines entirely using Annotation, the refline plot itself is just a convenience to avoid having to use the Annotate facility).
You may want to consider asking this question on http://communities.sas.com and seeing if one of the developers (Sanjay, Dan H, etc.) has a workaround or can suggest something specific other than annotation. If you do I suggest you include an example like the above so the question is clear.
Upvotes: 0
Reputation: 21274
I cannot replicate your issue. Here's code that doesn't replicate your issue. This means either you've set something else somewhere else that's causing this or you could be using a different version. I'm on SAS 9.4 TS1M3. In the future please include code so we can replicate your issue.
proc sgplot data=sashelp.stocks(where=(stock='IBM'));
series x=date y=open;
refline '01Jul2002'd / axis=x label = "[1]"
labelloc=outside labelpos=max labelattrs=(size=6.5pt family="arial");
run;
Upvotes: -1