[ncl-talk] lbLabelFormat functionality request.

Mary Haley haley at ucar.edu
Tue Jan 20 10:48:08 MST 2015


Hi Alan,

This is an issue for me as well, and I was surprised to see there's no
ticket for this. I just created one (NCL-2125).

I don't think this is a bug. It's simply an oversight that we never created
a "format" type of resource for labelbar labels.

You can work around this somewhat awkwardly by:

   - Creating the plot (set res at gsnDraw = False and res at gsnFrame = False)
   - Retrieving the "cnLineLabelStrings" resource to get the formatted
   strings
   - Setting "res at lbLabelStrings" to this retrieved resource
   - Recreating the plot with the newly added lbLabelStrings resource

You can also set lbLabelStrings the first time you create the plot, but
then you would have to use "sprintf" as you mentioned above.

I've attached a modified version of your script that uses the method
outlined above.

--Mary


On Tue, Jan 20, 2015 at 9:57 AM, Alan Brammer <abrammer at albany.edu> wrote:

> NCLers.
>
> I would like to be able to format a color bar label, without using
> sprintf.  It seems that cnLineLabelFormat
> <https://www.ncl.ucar.edu/Document/Graphics/Resources/cn.shtml#cnLineLabelFormat>
> claims that it should do this job but for me today it is not making any
> difference to the label bar.
>
> Am I missing a step or something? cnLineLabelFormat does it's job nicely
> on the plot, but has no impact on the labelbar.
>
>
> Request:
> Existence of an lbLabelFormat resource,  that is potentially linked to
> cnLineLabelFormat when not defined itself.
>
> For now I will stick to creating my own array of labels, and pumping them
> through sprintf.
>
>
> Thanks,
>      ~Alan.
>
>
>
> example code of cnLineLabelFormat not affecting the label bar below:
>
> x = fspan(-5, 5, 100)
> data = new( (/100,100/), float)
> do y=0, 99
> data(y,:) = exp(( -(x^2)/4) - (((x(y))^2)))   ;; quick way of creating
> some nice data to plot.
> end do
>
> wks = gsn_open_wks("x11","")
>
> res = True
> res at cnFillOn = True
> res at cnFillMode= "RasterFill"
> res at cnLinesOn = False
> res at cnLineLabelsOn = True
> res at cnLineLabelFormat = "0@;*.4f"
> res at lbAutoManage = False
> res at lbOrientation = "vertical"
> plot = gsn_csm_contour(wks, data, res)
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150120/09f360b6/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: contour_label_format.ncl
Type: application/octet-stream
Size: 880 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150120/09f360b6/attachment.obj 


More information about the ncl-talk mailing list