BookmarkSubscribeRSS Feed
Quentin
Super User

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.

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
3 REPLIES 3
Rick_SAS
SAS Super FREQ

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.

Jay54
Meteorite | Level 14

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

Quentin
Super User

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.

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1078 views
  • 0 likes
  • 3 in conversation