Data visualization with SAS programming

curvelabel inconsistencies?

Reply
Trusted Advisor
Posts: 1,149

curvelabel inconsistencies?

Hi,

This is an annoyingly vague question, but wondering if people have experienced odd inconsistencies with using CURVELABEL to label a line in SGPLOT/SGRENDER.

I'm still new to statistical graphics, but seems like when I have a complex (?) plot, and a handful of lines labeled via CURVEVABEL, and I'm generating a bunch of plots, often one label seems to end up in some bizarre location.   I usually use curvelabeloc=outside, and sometimes I will have a label floating somewhere in the middle of the plot.  I'm running 9.3.1M2.

Because of these odd experiences, I've started avoiding use of CURVELABEL.  And instead I label the curves manually using SGANNO (for SGPLOT) or DRAWTEXT (for GTL).  When I do things manually, I get what I want, but of course it's a lot more work than just writing /CurveLabel.

It looks like CurveLabel may try to avoid overlapping labels.  So that could be part of the problem I guess, but when I've seen this happen, the label isn't even close to where it "should" be.

Now that it's a Friday afternoon and I have time to try to replicate the problem with a small example, of course I cannot.  So for now, just wondering if anyone else has experienced odd inconsistencies with CURVELABEL?

I don't want to give up on CURVELABEL too soon,.  So if nobody else has seen bizarrely positioned labels come from CURVELABEL, I will assume I'm doing something odd, and give it another shot the next time I'm developing a new batch of plots.

Thanks,

--Q.

SAS Super FREQ
Posts: 3,232

Re: curvelabel inconsistencies?

I think I've seen this.  I am not a fan of the collision avoidance algorithm for the reasons that you give.  I think the problems that I've seen occured when the labels collided in specific places, like corners. The algorithm will try to move the label nearby, but because of the corner it has fewer choices.

Here's another possibility (just guessing). Maybe your label variable had a large length and that was the source of the problem. Next time you see this situation, see if adding the statement:

     format MyVarName $10.;

makes any difference. I find that shorter labels collide less frequently.

SAS Super FREQ
Posts: 1,044

Re: curvelabel inconsistencies?

Yes, label collision avoidance is less than ideal.  The algorithm for Location=OUTSIDE is designed for a specific use case of the Power procedures.  The labels are moved away from a central label, and for a dense plot, this can be less than ideal for the general use case.

The default setting is CurveLabelLoc=INSIDE.  In this case, the label is placed at the end of the curve, in the direction of the slope of the last line segment.  Have you tried that?  Here is an example:

CurveLabel1.png

Trusted Advisor
Posts: 1,149

Re: curvelabel inconsistencies?

Thanks Rick and Sanjay,

Glad I'm not the only one who has seen odd label positions.  Of course, I can see how it would be difficult to develop an "ideal" collision avoidance system, as people will differ on what they like to see. 

For yesterday's batch of graphs I put out, I just used DRAWTEXT and let them collide on occasion.  The rare collision didn't bother me, but I'm guessing I'll end up revisiting this in the next round of refactoring...

Thanks for the tip Sanjay on changing back to the default CurveLabelLoc=INSIDE.  Will have to play with that.  Looks nice.

Post a Question
Discussion Stats
  • 3 replies
  • 264 views
  • 0 likes
  • 3 in conversation