Re: Labels shown on a labelbar for a contour plot

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Thu, 29 Mar 2007 14:34:37 -0600

Hi Bruce,

> * The format of the numbers, e.g. can I say specify
> F4.2 for how the numbers are formatted ?

You cannot set the format of the labels like you can the tickmarks using
tmXBFormat for example. However, you can explicitly set the label bar
labels by setting cnExplicitLabelBarLabelsOn = True and by setting
lbLabelStrings appropriately:
http://www.ncl.ucar.edu/Document/Graphics/Resources/cn.shtml#cnExplicitLabelBarLabelsOn
http://www.ncl.ucar.edu/Document/Graphics/Resources/lb.shtml#lbLabelStrings

res_at_cnExplicitLabelBarLabelsOn = True
res_at_lbLabelStrings = (/"-001.0000","0001","2","3","Hi"/)

> * The labels which are shown, e.g. only draw boxes/lines
> and labels for numbers which are spaced by a given
> increment (say every 0.5 units) or which are specified
> by me (for example can I tell the NCL to only show/draw
> the labels for 2.2,2.6,3.0 on the labelbar when I am
> using the contour levels between those numbers to color
> the plot ?).

Sort of. You can set which labelbar labels shown using lbLabelStrings.
Let's say you have contours at -2,-1,0,1,2.5, but only want to show
labelbar labels at -1,1 and 2.5:

res_at_lbLabelStrings = (/"","-1.0","","1.0","2.5"/)

I don't know if I am understanding what you are wanting completely, but
if you can't find the resources in the label bar resource page
http://www.ncl.ucar.edu/Document/Graphics/Resources/lb.shtml

that do what you want, you do have the option to create the label bar
yourself. Take a look at example #5 here:
http://www.ncl.ucar.edu/Applications/labelbar.shtml

Good luck,
Adam

Lunde, Bruce N CIV NAVOCEANO, NP1 wrote:
> Hello,
>
> I was wondering if it is possible to control the
> following on the LabelBar of a contour plot:
>
> * The format of the numbers, e.g. can I say specify
> F4.2 for how the numbers are formatted ?
>
> * The labels which are shown, e.g. only draw boxes/lines
> and labels for numbers which are spaced by a given
> increment (say every 0.5 units) or which are specified
> by me (for example can I tell the NCL to only show/draw
> the labels for 2.2,2.6,3.0 on the labelbar when I am
> using the contour levels between those numbers to color
> the plot ?).
>
> THE CATCH is that I wish to use ALL of the colors in the
> colormap for the plot, so that the data is shown with
> smoothly varying colors.
>
> Excerpts from my code follow (which does not give desired result):
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" ;..
> flt2string()
>
> begin
> ...
> ...
> gsn_define_colormap(wks,"rainbow")
> the_color_map = gsn_retrieve_colormap(wks)
> temp = dimsizes(the_color_map)
> num_colors = temp(0)
>
> indexC1 = NhlNewColor(wks,0.70,0.70,0.70)
> indexC2 = NhlNewColor(wks,1.00,0.60,0.90) ;.. My polygon color
>
> res0 = res
> res0_at_gsnSpreadColors = True ;.. Use full range of colormap
>
> ;.. Color index 0 is background (default=white)
> ;.. Color index 1 is foreground (default=black)
>
> res0_at_gsnSpreadColorStart = 2 ;.. Start at color 3 = color index 2
> res0_at_gsnSpreadColorEnd = -3 ;.. If added TWO new color.
>
> res0_at_mpLandFillColor = indexC1
>
> res0_at_cnFillOn = True ; turn on color
> res0_at_cnLinesOn = False ; no contour lines
> res0_at_cnFillDrawOrder = "PreDraw"
> res0_at_cnFillMode = "RasterFill" ; turn on raster mode
>
> res0_at_cnLevelSelectionMode = "EqualSpacedLevels"
> res0_at_cnMaxLevelCount = num_colors
>
> res0_at_cnMinLevelValF = -1.4 ; set min contour level
> res0_at_cnMaxLevelValF = 1.5 ; set max contour level
>
> res0_at_cnLabelBarEndLabelsOn = True ; turn on end labels
>
> ;.......................................................................
> ........
> res0_at_lbOrientation = "Vertical" ; vertical label bar
>
> res0_at_lbLabelAutoStride = True
> res0_at_lbAutoManage = False
> ...
> ...
> plot1 = gsn_csm_contour_map_ce(wks, rdata, res0) ; contour the
> variable
> ...
> ...
> end
>
>
>
> =====
> Bruce Lunde
> Bruce.Lunde_at_navy.mil
> 228-688-5843
> Code NP1
> Naval Oceanographic Office
> Stennis Space Center, MS
> =====
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
--------------------------------------------------------------
Adam Phillips			             asphilli_at_ucar.edu
National Center for Atmospheric Research   tel: (303) 497-1726
ESSL/CGD/CAS                               fax: (303) 497-1333
P.O. Box 3000				
Boulder, CO 80307-3000	  http://www.cgd.ucar.edu/cas/asphilli
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Mar 29 2007 - 14:34:37 MDT

This archive was generated by hypermail 2.2.0 : Sun Apr 01 2007 - 11:52:47 MDT