[ncl-talk] Incorrect label bar

Beata Szabo szabo.b at czechglobe.cz
Thu Sep 22 03:06:40 MDT 2016


I added
resP at lbBoxCount = 5

but unfortunately it does not help. I created new netcdf files with same
variables, but I converted the unep variable to integer and I also tried
to draw the maps with those integer variables (1,2,3,4,5) with

  res at cnLevels              = (/1,2,3,4,5/)

The resulted maps are correct but the label is still incorrect both with
string and without string labels. I attached the sript and the created
maps. I would appreciated if someone helped me!

Beata

> I don't know for certain, but you might try adding
>
>    resP at lbBoxCount = 5
>
> I'm not positive that will fix it, but the docs say that the sizes of
> arrays like lbLabelStrings, etc, must match the lbBoxCount, and in your
> case it sounds like its defaulting to 11 (?)
>
> Hope that helps...
> Rick
>
>
> On Wed, Sep 21, 2016 at 2:12 AM, Beata Szabo <szabo.b at czechglobe.cz>
> wrote:
>
>> I created a panel plot with my own netCDF files and color table be
>> created
>> according to
>> http://www.ncl.ucar.edu/Document/Graphics/create_color_table.shtml
>>
>> My own color table has ncolors = 5. The netCDF files contains five float
>> values (1.0, 2.0, 3.0, 4.0, 5.0). After I run the below script I
>> received
>> correct maps with incorrect labelbar. The labelbar containes 11 box
>> where
>> the first two and the last two colors are two times and the third color
>> roles three times. Moreover the label strings are the follows: Arid,
>> Sub-humid, Label_6, Label_8.
>>
>> How can I create a correct labelbar?
>>
>> ;----------------------------------------------------------------------
>> ; Main code.
>> ;----------------------------------------------------------------------
>> begin
>> ;************************************************
>> ; read in netCDF file
>> ;************************************************
>>   a = addfile("UNEP_E-OBS_sm.nc","r")
>>   b = addfile("UNEP_1971-2000_sm.nc","r")
>>   c = addfile("UNEP_2021-2050_sm.nc","r")
>>   d = addfile("UNEP_2071-2100_sm.nc","r")
>>
>>   un1 = a->unep(:,:)
>>   un2 = b->unep(:,:)
>>   un3 = c->unep(:,:)
>>   un4 = d->unep(:,:)
>>
>>   minlat             =  30                ; min lat to mask
>>   maxlat             =  75                ; max lat to mask
>>   minlon             = -20                ; min lon to mask
>>   maxlon             =  40                ; max lon to mask
>>
>> ;************************************************
>> ; create plot
>> ;************************************************
>>   wks = gsn_open_wks("png","unep")            ; send graphics to PNG
>> file
>>
>>   cmap = read_colormap_file("aridity")
>>
>>
>>
>>   plot = new(4,graphic)
>>   res                       = True              ; plot mods desired
>>   res at gsnMaximize           = True              ; enlarge plot
>>   res at gsnDraw               = False             ; Don't draw yet
>>   res at gsnFrame              = False             ; Don't advance frame
>> yet
>>   res at mpProjection          = "LambertConformal"; choose projection
>>
>>   res at cnFillOn              = True              ; turn on color
>>   res at cnLinesOn             = False             ; turn off contour lines
>>   res at lbLabelBarOn          = False
>>   res at cnFillPalette         = cmap(::-1,:)         ; set color map
>>
>>   res at mpMinLatF             = minlat
>>   res at mpMaxLatF             = maxlat
>>
>>   res at mpMinLonF             = minlon
>>   res at mpMaxLonF             = maxlon
>>
>>   res at gsnMaskLambertConformal = True            ; turn on lc masking
>>   res at mpGridAndLimbOn         = True
>>   res at mpGridLatSpacingF       = 10
>>   res at mpGridLonSpacingF       =  5
>>   res at gsnAddCyclic            = False
>>
>>   res at tiMainString            = ""
>>   res at tiMainOffsetYF          = 0.01   ; Move title up a little
>>   res at gsnRightString          = "A"
>>   res at gsnLeftString           = ""
>> ;  pr&lon = pr&lon-180                             ; make lon go -180 to
>> 180
>>
>>   plot(0)  =
>> gsn_csm_contour_map(wks,un1({minlat:maxlat},{minlon:maxlon}),res);
>> create plot
>>
>>   resb                       = True              ; plot mods desired
>>   resb at gsnMaximize           = True              ; enlarge plot
>>   resb at gsnDraw               = False             ; Don't draw yet
>>   resb at gsnFrame              = False             ; Don't advance frame
>> yet
>>   resb at mpProjection          = "LambertConformal"; choose projection
>>
>>   resb at cnFillOn              = True              ; turn on color
>>   resb at cnLinesOn             = False             ; turn off contour
>> lines
>>   resb at lbLabelBarOn          = False
>>   resb at cnFillPalette         = cmap(::-1,:)         ; set color map
>>
>>   resb at mpMinLatF             = minlat
>>   resb at mpMaxLatF             = maxlat
>>
>>   resb at mpMinLonF             = minlon
>>   resb at mpMaxLonF             = maxlon
>>
>>   resb at gsnMaskLambertConformal = True            ; turn on lc masking
>>   resb at mpGridAndLimbOn         = True
>>   resb at mpGridLatSpacingF       = 10
>>   resb at mpGridLonSpacingF       =  5
>>   resb at gsnAddCyclic            = False
>>
>>   resb at tiMainString            = ""
>>   resb at tiMainOffsetYF          = 0.01   ; Move title up a little
>>   resb at gsnRightString          = "B"
>>   resb at gsnLeftString           = ""
>>
>>   plot(1)  =
>> gsn_csm_contour_map(wks,un2({minlat:maxlat},{minlon:maxlon}),resb);
>> create plot
>>
>>   resc                       = True              ; plot mods desired
>>   resc at gsnMaximize           = True              ; enlarge plot
>>   resc at gsnDraw               = False             ; Don't draw yet
>>   resc at gsnFrame              = False             ; Don't advance frame
>> yet
>>   resc at mpProjection          = "LambertConformal"; choose projection
>>   resc at cnFillOn              = True              ; turn on color
>>   resc at cnLinesOn             = False             ; turn off contour
>> lines
>>   resc at lbLabelBarOn          = False
>>   resc at cnFillPalette         = cmap(::-1,:)         ; set color map
>>
>>   resc at mpMinLatF             = minlat
>>   resc at mpMaxLatF             = maxlat
>>
>>   resc at mpMinLonF             = minlon
>>   resc at mpMaxLonF             = maxlon
>>
>>   resc at gsnMaskLambertConformal = True            ; turn on lc masking
>>   resc at mpGridAndLimbOn         = True
>>   resc at mpGridLatSpacingF       = 10
>>   resc at mpGridLonSpacingF       =  5
>>   resc at gsnAddCyclic            = False
>>
>>   resc at tiMainString            = ""
>>   resc at tiMainOffsetYF          = 0.01   ; Move title up a little
>>   resc at gsnRightString          = "C"
>>   resc at gsnLeftString           = ""
>>
>>
>>   plot(2)  =
>> gsn_csm_contour_map(wks,un3({minlat:maxlat},{minlon:maxlon}),resc);
>> create plot
>>
>>
>>   resd                       = True              ; plot mods desired
>>   resd at gsnMaximize           = True              ; enlarge plot
>>   resd at gsnDraw               = False             ; Don't draw yet
>>   resd at gsnFrame              = False             ; Don't advance frame
>> yet
>>   resd at mpProjection          = "LambertConformal"; choose projection
>>
>>   resd at cnFillOn              = True              ; turn on color
>>   resd at cnLinesOn             = False             ; turn off contour
>> lines
>>   resd at lbLabelBarOn          = False
>>   resd at cnFillPalette         = cmap(::-1,:)         ; set color map
>>
>>   resd at mpMinLatF             = minlat
>>   resd at mpMaxLatF             = maxlat
>>
>>   resd at mpMinLonF             = minlon
>>   resd at mpMaxLonF             = maxlon
>>
>>   resd at gsnMaskLambertConformal = True            ; turn on lc masking
>>   resd at mpGridAndLimbOn         = True
>>   resd at mpGridLatSpacingF       = 10
>>   resd at mpGridLonSpacingF       =  5
>>   resd at gsnAddCyclic            = False
>>
>>   resd at tiMainString            = ""
>>   resd at tiMainOffsetYF          = 0.01   ; Move title up a little
>>   resd at gsnRightString          = "D"
>>   resd at gsnLeftString           = ""
>>
>>
>>   plot(3)  =
>> gsn_csm_contour_map(wks,un4({minlat:maxlat},{minlon:maxlon}),resd);
>> create plot
>>
>> ;---Attach latitude labels
>>   add_lc_labels(wks,plot(0),minlat,maxlat,minlon,maxlon)
>>   add_lc_labels(wks,plot(1),minlat,maxlat,minlon,maxlon)
>>   add_lc_labels(wks,plot(2),minlat,maxlat,minlon,maxlon)
>>   add_lc_labels(wks,plot(3),minlat,maxlat,minlon,maxlon)
>>
>> ;---Drawing the plot will also draw all the attached labels.
>>   draw(plot(0))
>>   draw(plot(1))
>>   draw(plot(2))
>>   draw(plot(3))
>>   frame(wks)
>>    ;-- create panel plot
>> ;************************************************
>>     resP                     = True                ; modify the panel
>> plot
>>
>>     resP at gsnPanelLabelBar    = True                ; add common colorbar
>>     resP at lbLabelFontHeightF  = 0.007               ; make labels smaller
>>     resP at cnExplicitLabelBarLabelOn = True
>>
>>     resP at lbLabelStrings = (/"","Hyper-arid","Arid", \
>>            "Semi-arid","Sub-humid","Humid"/)
>>
>>     gsn_panel(wks,plot,(/2,2/),resP)
>>
>> end
>>
>> Thank you for your help in advance!
>>
>> Beata
>>
>>
>> Dr. Beata Szabo-Takacs
>> Global Change Research Institute CAS
>> Bělidla 986/4a
>> 60300 Brno
>> Czech Republic
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>


Dr. Beata Szabo-Takacs
Global Change Research Institute CAS
Bělidla 986/4a
60300 Brno
Czech Republic
-------------- next part --------------
A non-text attachment was scrubbed...
Name: unep.ncl
Type: application/octet-stream
Size: 12525 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160922/c47e30f2/attachment-0001.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: unep_without_string_labels.png
Type: image/png
Size: 270088 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160922/c47e30f2/attachment-0002.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: unep_with_string_labels.png
Type: image/png
Size: 270130 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160922/c47e30f2/attachment-0003.png 


More information about the ncl-talk mailing list