Fanning Software Consulting

Text Object Scaling

QUESTION: When I add new data with a different data range to my object graphics plot object or surface object, the annotation on the axes becomes unreadable. What can I do to prevent this?

ANSWER: The problem here is that the new data causes the axes to scale differently. The annotation, which is a text object associated with each axis, is also automatically scaled at the same time. This is what is causing the problem for you.

What you want to do is recompute the proper dimensions of the text object in terms of the new axis scaling. Unfortunately, this is not done automatically for you when you create the text object. Rather, when the text object dimensions are recomputed is left up to you. By default the dimensions are never recomputed, leading to the problems you are observing.

But by setting the Recompute_Dimensions keyword of the axis text object to 2, you can recompute the proper dimensions of the text object whenever the axis range changes. I like to do this at the same time I am setting the font of an axis. My code will look something like this:

   xAxisObject = Obj_New("IDLgrAxis", 0, Color=[0,255,0], Ticklen=0.1, $
      Minor=4, Title=xtitleObj, Range=xrange, Exact=Keyword_Set(exact))
   xAxisObject->GetProperty, Ticktext=xAxisTextObject
   helvetica10ptFontObject = Obj_New('IDLgrFont', 'Helvetica', Size=10)
   xAxisTextObject->SetProperty, Font=helvetica10ptFontObject, Recompute_Dimensions=2

Google
 
Web Coyote's Guide to IDL Programming