Re: categorical label-bar question

From: Erik N <nobleeu_at_nyahnyahspammersnyahnyah>
Date: Mon Jul 09 2012 - 15:07:51 MDT

Thank you Mary, I solved this by changing my font from Helvetica-Bold
to just Helvitica. I want to use Helvetica Bold though, I will try
your suggestions.

On Thu, Jul 5, 2012 at 11:49 PM, Mary Haley <haley@ucar.edu> wrote:
> If you are using V6.1.0-beta, then lbLabelAutoStride is set to True.
> Try setting it to False.
>
> If this doesn't work, try setting lbLabelStride = 1.
>
> --Mary
>
> On Jul 4, 2012, at 10:13 AM, Erik N wrote:
>
>> Hi, I used the 1st example on Classification (Categorical) Data page
>> to make the following plot ( attached).
>> I want the label bar to go from 1 to 24. For some reason the label bar
>> is not starting at "1" and is only plotting every 2nd number, even
>> though I use the command(s):
>>
>> res@lbOrientation = "vertical"
>> res@lbLabelPosition = "Center" ; label position
>> res@lbLabelAlignment = "BoxCenters" ; label orientation
>> res@lbLabelStrings = ispan(1,24,1)
>>
>> How may I fix this?
>> Thank you ahead of time.
>>
>> Sincerely.
>> --
>> - Erik -
>>
>>
>>
>> SCRIPT
>> ________
>>
>>
>> ;================================================
>> ; based on vegland_1.ncl
>> ;================================================
>> ; Concepts illustrated:
>> ; - Creating a vegetation classification plot using raster contours
>> ; - Plotting "byte" data
>> ; - Customizing a labelbar for a contour plot
>> ; - Centering labels with respect to labelbar boxes
>> ; - Changing the width and height of a labelbar
>> ; - Centering the labels inside each box in a labelbar
>> ; - Changing the labelbar labels
>> ; - Drawing text on the frame using NDC coordinates
>> ; - Using the "where" function to create a land-sea mask
>> ;================================================
>>
>> 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"
>>
>> begin
>> diri = "./" ; input directory
>> fili = "post_wrfout_d01_2006-09-02_00:00:00.nc"
>> ;---read in data
>> dir = "./"
>> a = addfile(diri+fili,"r")
>> veg = a->LandUse(0,:,:)
>>
>> lat = a->latitude
>> lat!0 = "lat"
>> lat@units = "degrees_north"
>> lon = a->longitude
>> lon!0 = "lon"
>> lon@units = "degrees_east"
>> latRange = (/min(lat), max(lat)/)
>> lonRange = (/min(lon), max(lon)/)
>> ; Add meta data for plotting purposes
>> ;fix ; go back laveg and fix in wrf script
>> veg!0 = "lat"
>> veg!1 = "lon"
>> veg&lat = lat
>> veg&lon = lon
>>
>>
>> info = (/ " 1 Urban or Built Land", \ ; n=0
>> " 2 Dry C&P ", \
>> " 3 Irrigated C&P", \
>> " 4 Mixed C&P ", \
>> " 5 Cropland/Grassland", \
>> " 6 Cropland/Woodland", \
>> " 7 Grassland", \
>> " 8 Shrubland", \
>> " 9 Mixed Shrub/Grass", \
>> "10 Savanna", \
>> "11 Deciduous Broadleaf", \
>> "12 Deciduous Needleleaf", \
>> "13 Evergreen Broadleaf", \
>> "14 Evergreen Needleleaf", \
>> "15 Mixed Forest", \
>> "16 Water Bodies ", \
>> "17 Herbaceous Wetland", \
>> "18 Wooden Wetland", \
>> "19 Barren", \
>> "20 Herbaceous Tundra", \
>> "21 Wooded Tundra", \
>> "22 Mixed Tundra", \
>> "23 Bare Ground Tundra", \
>> "24 Snow or Ice" /) ; n=23
>>
>> colors = (/ "white","black","purple", \ ; n=0
>> "coral", \ ;2
>> "coral2", \ ;3
>> "chocolate1", \ ;4
>> "lightgoldenrod1", \ ;5
>> "chocolate4", \ ;6
>> "darkolivegreen2", \ ;7
>> "darkolivegreen1", \ ;8
>> "greenyellow", \ ;9
>> "darkolivegreen3", \
>> "green2", \
>> "darkkhaki", \
>> "darkolivegreen", \
>> "darkgreen", \
>> "limegreen", \
>> "blue", \ ; water; deepskyblue2
>> "orange1", \
>> "orange3", \
>> "gold1", \
>> "lightslategrey", \
>> "lightsteelblue2", \
>> "lightsteelblue1", \
>> "lightyellow3", \
>> "lightyellow1" /) ; n=23
>>
>>
>> ;************************************************
>> ; create plot
>> ;************************************************
>>
>> wks = gsn_open_wks("pdf","domain_veg")
>> gsn_define_colormap(wks, colors)
>> res = True ; plot mods desired
>> res@gsnDraw = False
>> res@gsnFrame = False
>> ; res@gsnMaximize = True
>>
>> res@cnFillOn = True ; color Fill
>> res@cnFillMode = "RasterFill" ; Raster Mode
>> res@cnLinesOn = False ; Turn off contour lines
>>
>> res@cnLevelSelectionMode = "ExplicitLevels" ; set explict contour levels
>> res@cnLevels = integertobyte( ispan(2,24,1) )
>>
>> res@lbOrientation = "vertical"
>> res@lbLabelPosition = "Center" ; label position
>> res@lbLabelAlignment = "BoxCenters" ; label orientation
>> res@lbLabelStrings = ispan(1,24,1)
>>
>> ; res@pmLabelBarHeightF = 0.075
>> ;res@pmLabelBarWidthF = 0.60 ; default is 0.6
>> res@pmLabelBarOrthogonalPosF = -0.0005 ; move up smidge
>>
>> ;res@mpCenterLonF = 0 ; set map center
>> res@mpFillOn = False
>>
>> ;=======;zoom part
>> res@gsnAddCyclic = False
>> ;res@mpProjection = "Mercator"
>> res@mpLimitMode = "Corners"
>> res@mpLeftCornerLatF = latRange(0)
>> res@mpLeftCornerLonF = lonRange(0)
>> res@mpRightCornerLatF = latRange(1)
>> res@mpRightCornerLonF = lonRange(1)
>> res@pmTickMarkDisplayMode = "Always" ; Toggle b/t these two for
>> tick mark effect
>> res@mpGridAndLimbOn = True
>> res@mpGridSpacingF = 5
>> res@mpGridLineThicknessF = 1.0
>> res@mpGridLineColor = "Gray30"
>> res@tmXBTickSpacingF = 15
>> res@tmYLTickSpacingF = 10
>> res@tmXBLabelFontHeightF = 0.015
>> res@tmYLLabelFontHeightF = 0.015
>>
>> res@mpFillOn = False
>> res@gsnLeftString = "Land Use"
>> res@gsnCenterString = "WRF Model Domain"
>> res@gsnRightString = "USGS Categories"
>> res@txFontHeightF = 0.015
>> res@pmTickMarkDisplayMode = "Always" ; Toggle b/t these two for
>> tick mark effect
>>
>> plot = gsn_csm_contour_map_ce(wks, veg, res) ; create plot
>>
>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>> ;Overlay boxes over regions
>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>> ;************************************************
>> ; create points for box1
>> ;************************************************
>> ypts1 = (/ 20.0, 20.0, 5.0, 5.0, 20.0/)
>> xpts1 = (/-20.0, 10.0,10.0, -20.0,-20.0/)
>> ;************************************************
>> ; add the boxes
>> ;************************************************
>> res1 = True ; polyline mods desired
>> res1 = res
>> res1@gsLineColor = "red" ; color of lines
>> res1@gsLineThicknessF = 8.0 ; thickness of lines
>> ; create array of dummy graphic variables. This is required, b/c each line
>> ; must be associated with a unique dummy variable.
>> dum1 = new(4,graphic)
>> ; draw each line separately. Each line must contain two points.
>> do i = 0 , 3
>> dum1(i)=gsn_add_polyline(wks,plot,xpts1(i:i+1),ypts1(i:i+1),res1)
>> end do
>> ;************************************************
>> ; label the box with additional text
>> ;************************************************
>> ; tres = True
>> ; tres@txFontHeightF = 0.015
>> ; tres@txFontColor = "red"
>> ; gsn_text(wks,plot,"Sahel",0.0,13.0,tres)
>>
>> ; Catagories
>> rtxt = True
>> rtxt@txJust = "CenterLeft"
>> rtxt@txFontHeightF = 0.009
>> ; 4 rows x 6 columns of text
>> n = -1
>> xx = .04
>> do ncol=0,5
>> yy = 0.16
>> do nrow=0,3
>> n = n+1
>> gsn_text_ndc (wks,info(n),xx,yy,rtxt)
>> yy = yy - 3*rtxt@txFontHeightF
>> end do
>> xx = xx + 0.155
>> end do
>>
>>
>> draw(plot)
>> frame(wks)
>>
>> end
>> <domain_veg.pdf>_______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

-- 
- Erik -
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jul 9 15:08:05 2012

This archive was generated by hypermail 2.1.8 : Thu Jul 12 2012 - 10:16:50 MDT