03-22-2013 04:25 PM
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.
03-23-2013 06:47 AM
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.
03-23-2013 03:18 PM
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:
03-23-2013 03:55 PM
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.