Re: Label bar positioning

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Tue, 7 Jul 2009 15:34:06 -0600

Jack,
Yes I see. I should have noted that you are trying to adjust a
"managed" labelbar. The calculation seems basically correct but
perhaps I am forgetting a detail or two. Can you send a small script
that demonstrates how the calculation leads to an incorrect location
for the auxiliary text?
Thanks.
  -dave

On Jul 7, 2009, at 3:11 PM, Jack Glendening wrote:

> Dave
>
> Thanks for that information but I see it describes only useage
> using "lb" resources and not the "pm" resources which control the
> labelbar. My need is simply to create a significantly smaller
> labelbar
> and was assuming/hoping I could just use the "pm" LabelBar resources,
> since I thought this was exactly the sort of case for which they were
> intended (see my example below, which was mangled when I sent my
> original posting).
>
> yNDCmidLabelbar = vpYF - vpHeightF - pmLabelBarOrthogonalPosF -
> 0.5*pmLabelBarHeightF
>
> Is there any info on how the pm LabelBar resources should be used, or
> how they interact with the lb resources ?
>
> Jack
>
>
> On Tuesday 07 July 2009 13:55, you wrote:
>> Hi Jack,
>> I am attaching a script "labelbar.ncl" that demonstrates how to
>> position the top left corner of the labelbar at an exact point. It
>> creates a vertical labelbar but the same principles apply for a
>> horizontal bar and any other justification point. I am also including
>> an explanation of all the resources that apply to the sizing of a
>> labelbar that I sent to Oliver Fuhrer a couple of months ago.
>> -dave
>>
>> Hi Oliver,
>>
>> Actually it turns out that there are LabelBar resources that allow
>> you to ensure that the corner of the colorbar is positioned precisely
>> at the justification point. I am enclosing a variation on your test
>> script that demonstrates how to do it. I will try to explain how it
>> all works.
>>
>> By default, with lbAutoManage set to True, the LabelBar code makes
>> sure that all elements of the LabelBar fit inside the width and
>> height specified using vpWidthF and vpHeightF. This requires that the
>> LabelBar controls the font height of the labels. However, depending
>> on other constraints this often leads to text that is too small. To
>> achieve control of the font height, you need to turn lbAutoManage
>> off. Once the user controls the font height, the LabelBar can no
>> longer ensure that everything will fit inside the specified width and
>> height, but it still tries to if it can.
>>
>> A significant resource for your application is lbBoxMinorExtentF.
>> This specifies the proportion of the space in the direction
>> perpendicular to the labelbar orientation that is occupied by the
>> colorbar. By default it is 0.33, or 1/3 of the width specified by
>> vpWidthF in the case of a vertically oriented labelbar. The total
>> width is accounted for by 5 elements: the left margin, the colorbar
>> (box) width, the label offset (which specifies a space between the
>> colorbar and the labels), the width of the longest text string, and
>> finally the right margin. If all of these together amount to less
>> than the width specified by vpWidthF, then the colorbar and the text
>> are centered within the available width. This is what leads to the
>> variable distance from the specified position of the top left corner
>> of the colorbar.
>>
>> By the way, it is actually not necessary to draw a polyline to trace
>> the outer boundary of the labelbar. You can simply set the resource
>> lbPerimOn to True.
>>
>> To ensure that the top-left corner of the colorbar falls on the
>> specified point, set the resources as follows:
>>
>> lbJustification = "topleft"
>> lbLeftMarginF = 0.0
>> lbTopMarginF = 0.0 ; eliminate any margin at the top and left of
>> the colorbar
>> lbBoxMinorExtentF = 1.0 ; this makes the colorbar width equal to
>> the full amount of vpWidthF. As a side effect this results in the
>> labels being drawn entirely outside the labelbar viewport
>>
>> vpWidthF = .03 ; reduced from 0.1 to maintain approximately the
>> colorbar width of the original plot.
>>
>> lbLabelOffsetF = .5 ; this specifies the offset between the colorbar
>> and the labels as a fraction of vpWidthF (for a vertically oriented
>> labelbar). Since vpWidthF has become smaller, this value needs to be
>> increased to maintain approximately the original distance between the
>> colorbar and the labels.
>>
>> lbLabelAutoStride = True ; (optional) this ensures that labels do
>> not overlap when the font height is made very large.
>>
>> Note that if the text becomes very large the colorbar can still be
>> pushed down from the justification point because the text extends
>> above top end of the colorbar. Setting lbLabelAutoStride helps to
>> prevent this for large text.
>>
>> If you need to know the ultimate extent of the labelbar after setting
>> the resources in this manner, you can use NhlGetBB.
>>
>> Hope this helps.
>> -dave

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Jul 07 2009 - 15:34:06 MDT

This archive was generated by hypermail 2.2.0 : Wed Jul 08 2009 - 14:48:16 MDT