Re: Label bar positioning

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Tue, 7 Jul 2009 14:55:53 -0600

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.

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.

On Jul 7, 2009, at 2:10 PM, Jack Glendening wrote:

> I am adding some text "ouboard" (i.e. to the left and right) of the
> labelbar. I've now had to greatly reduce the labelbar size for one
> particular case and find that my Y positioning is thrown off, with the
> text now appearing significantly below the Y center of the labelbar.
> The approach I had been taking for pmLabelBarSide = "Bottom" is
> yNDCmidLabelbarvpYF - vpHeightF - pmLabelBarOrthogonalPosF -
> 0.5*pmLabelBarHeightF
> It seems I must be omitting some other parameter which control the Y
> positioning of the labelbar. Any ideas as to what that parameter(s)
> might be?
> Jack
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:

ncl-talk mailing list
List instructions, subscriber options, unsubscribe:

Received on Tue Jul 07 2009 - 14:55:53 MDT

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