Hi, Adam,
Thanks a lot for your suggestion.
I added a line "res@cnLineLabelInterval = 1" to the code but it still does not work.
I think there may have some line repeated, but I can not find it.
The code is also attached and pasted as following.
Thanks a lot if anyone can help me out of this.
Wenjun
*******************************************************************************************************************
;************************************************
; Plot less CW winter average boundary layer height0utc6step anomaly
;************************************************
;************************************************
; create plot
;************************************************
wks = gsn_open_wks("ps","lesscw_winter_average_boundary_layer_height0utc6step_anomaly") ; open a ps file
gsn_define_colormap(wks,"rainbow")
res = True ; plot mods desired
;res@tiMainString = "Less CW winter average boundary layer height0utc6step anomaly (meter) ~C~ (95% significance)"
res@gsnAddCyclic = False ; The range of the longitude data is not 360, may want to set gsnAddCyclic to False to avoid a warning
res@cnFillOn = True ; turn on color fill
res@cnLinesOn = True ; turn on contour lines
res@cnMonoLineColor = True ; turn on the drawing of contours lines in one color
res@cnLineColor = "white" ; set the contour line color as "white"
res@gsnContourNegLineDashPattern = 2 ; set the contour line pattern as "dash"
res@gsnContourPosLineDashPattern = 11 ; set the contour line pattern as "dash"
res@gsnContourLineThicknessesScale = 1.8 ; set the contour lines thickness
res@gsnContourZeroLineThicknessF = 1.8 ; set the zero contour line thickness
res@cnInfoLabelOn = True ; turn on coutour information label
res@gsnSpreadColors = True
res@gsnSpreadColorStart = 2
res@gsnSpreadColorEnd = 255
res@lbOrientation = "vertical" ; vertical label bars
res@cnFillDrawOrder = "Predraw"
res@cnLineDrawOrder = "Predraw"
res@cnLevelSelectionMode = "ExplicitLevels" ; set explicit contour levels
res@cnLevels = (/-200,-150,-125,-100,-80,-60,-40,-20,0,20,40,60,80,100,125,150,200/)
res@cnLineLabelPlacementMode = "computed" ; define the contour Line Label Placement Mode
levels = (/-200,-150,-125,-100,-80,-60,-40,-20,0,20,40,60,80,100,125,150,200/)
nlev = dimsizes(levels)
;--------------------------------------------------
;set only to label the zero and positive labels
res@cnLevelSelectionMode = "ExplicitLevels"
res@cnLevels = levels
res@cnLineLabelInterval = 1
; Control which contour lines get drawn.
res@cnLevelFlags = (/"NoLine","NoLine","NoLine","NoLine", "NoLine","NoLine","NoLine","NoLine","LineAndLabel","NoLine","NoLine","NoLine", \
"NoLine","NoLine","NoLine","NoLine","NoLine"/)
lbstrings = new(nlev, "string")
;lbstrings = ""
lbstrings = where(levels .eq. 0, "0", 0)
print(lbstrings)
;lbstrings = where(levels .eq. 0.02, "0.02", lbstrings)
;lbstrings = where(levels .eq. 0.04, "0.04", lbstrings)
;lbstrings = where(levels .eq. 0.06, "0.06", lbstrings)
res@cnExplicitLineLabelsOn = True
res@cnLineLabelStrings = lbstrings
;--------------------------------------------------
res@mpFillOn = True ; turn on gray continents
;res@mpCenterLonF = 180 ; Centers the plot at 180
res@mpLimitMode = "LatLon"
;res@mpMinLonF = 72.
;res@mpMaxLonF = 136.
;res@mpMinLatF = 17.
;res@mpMaxLatF = 55.
res@mpMinLonF = 70.
res@mpMaxLonF = 140.
res@mpMinLatF = 15.
res@mpMaxLatF = 55.
;fill_specs = (/"water","land"/)
;res@mpFillBoundarySets = "NoBoundaries"
;res@mpFillAreaSpecifiers = fill_specs
;res@mpSpecifiedFillColors = (/"gray","gray"/)
res@mpAreaMaskingOn = 1
res@mpMaskAreaSpecifiers = (/"China","Taiwan"/)
;
; Set up some map resources.
;
;nc1 = NhlNewColor(wks,.7,.7,.7) ; Add light gray to colormap,
; for continents.
res = True
res@gsnMaximize = True ; Maximize plot in frame.
res@gsnFrame = False ; Don't advance the frame
res@mpDataSetName = "Earth..4" ; This new database contains
; divisions for other countries.
res@mpDataBaseVersion = "MediumRes" ; Medium resolution database
res@mpOutlineOn = True ; Turn on map outlines
res@mpOutlineSpecifiers = (/"China:states","Taiwan"/) ;China:states
res@mpGeophysicalLineThicknessF= 2. ; double the thickness of geophysical boundaries
res@mpNationalLineThicknessF= 2. ; double the thickness of national boundaries
;
; Zoom in on P. R. China.
;
res@mpMinLatF = 17.
res@mpMaxLatF = 55.
res@mpMinLonF = 72.
res@mpMaxLonF = 136.
;res@mpFillColors = (/-1,-1,nc1,-1/) ;assign light gray to land masses
res@mpFillColors = (/"transparent","transparent","transparent","transparent"/) ;fill land and ocean in transparent
res@cnInfoLabelOn = False ;Don't draw an informational label
plot = gsn_csm_contour_map_ce(wks,blh0utc6step_ave_lesscwyear_anomaly(:,:), res) ; create plot
*******************************************************************************************************************
Wen.J.Qu
2014-03-28
发件人: Adam Phillips
发送时间: 2014-03-28 03:01:09
收件人: Wen-Jun Qu; ncl-talk
抄送:
主题: Re: [ncl-talk] Why I can not label zero line in the contour
Hi Wenjun,
Try setting the resource cnLineLabelInterval to 1 . (The default is 2)
http://www.ncl.ucar.edu/Document/Graphics/Resources/cn.shtml#cnLineLabelInterval
If that does not fix the issue please respond to the ncl-talk email list..
Adam
On 03/27/2014 12:40 PM, Wen-Jun Qu wrote:
Hello, dear NCL friends,
I am try to draw a contour and label the zero line, but I failed many times.
Would anyone pls help me to find where is the bug?
I attached the code and also paste it as following.
Thanks a lot in advance.
Wenjun
******************************************************************************************************
;************************************************
; Plot less CW winter average boundary layer height0utc6step anomaly
;************************************************
;************************************************
; create plot
;************************************************
wks = gsn_open_wks("ps","lesscw_winter_average_boundary_layer_height0utc6step_anomaly") ; open a ps file
gsn_define_colormap(wks,"rainbow")
res = True ; plot mods desired
;res@tiMainString = "Less CW winter average boundary layer height0utc6step anomaly (meter) ~C~ (95% significance)"
res@gsnAddCyclic = False ; The range of the longitude data is not 360, may want to set gsnAddCyclic to False to avoid a warning
res@cnFillOn = True ; turn on color fill
res@cnLinesOn = True ; turn on contour lines
res@cnMonoLineColor = True ; turn on the drawing of contours lines in one color
res@cnLineColor = "white" ; set the contour line color as "white"
res@gsnContourNegLineDashPattern = 2 ; set the contour line pattern as "dash"
res@gsnContourPosLineDashPattern = 11 ; set the contour line pattern as "dash"
res@gsnContourLineThicknessesScale = 1.8 ; set the contour lines thickness
res@gsnContourZeroLineThicknessF = 1.8 ; set the zero contour line thickness
res@cnInfoLabelOn = True ; turn on coutour information label
res@gsnSpreadColors = True
res@gsnSpreadColorStart = 2
res@gsnSpreadColorEnd = 255
res@lbOrientation = "vertical" ; vertical label bars
res@cnFillDrawOrder = "Predraw"
res@cnLineDrawOrder = "Predraw"
res@cnLevelSelectionMode = "ExplicitLevels" ; set explicit contour levels
res@cnLevels = (/-200,-150,-125,-100,-80,-60,-40,-20,0,20,40,60,80,100,125,150,200/)
res@cnLineLabelPlacementMode = "computed" ; define the contour Line Label Placement Mode
levels = (/-200,-150,-125,-100,-80,-60,-40,-20,0,20,40,60,80,100,125,150,200/)
nlev = dimsizes(levels)
;--------------------------------------------------
;set only to label the zero and positive labels
res@cnLevelSelectionMode = "ExplicitLevels"
res@cnLevels = levels
; Control which contour lines get drawn.
res@cnLevelFlags = (/"NoLine","NoLine","NoLine","NoLine", "NoLine","NoLine","NoLine","NoLine","LineAndLabel","NoLine","NoLine","NoLine", \
"NoLine","NoLine","NoLine","NoLine","NoLine"/)
lbstrings = new(nlev, "string")
;lbstrings = ""
lbstrings = where(levels .eq. 0, "0", 0)
print(lbstrings)
;lbstrings = where(levels .eq. 0.02, "0.02", lbstrings)
;lbstrings = where(levels .eq. 0.04, "0.04", lbstrings)
;lbstrings = where(levels .eq. 0.06, "0.06", lbstrings)
res@cnExplicitLineLabelsOn = True
res@cnLineLabelStrings = lbstrings
;--------------------------------------------------
res@mpFillOn = True ; turn on gray continents
;res@mpCenterLonF = 180 ; Centers the plot at 180
res@mpLimitMode = "LatLon"
;res@mpMinLonF = 72.
;res@mpMaxLonF = 136.
;res@mpMinLatF = 17.
;res@mpMaxLatF = 55.
res@mpMinLonF = 70.
res@mpMaxLonF = 140.
res@mpMinLatF = 15.
res@mpMaxLatF = 55.
;fill_specs = (/"water","land"/)
;res@mpFillBoundarySets = "NoBoundaries"
;res@mpFillAreaSpecifiers = fill_specs
;res@mpSpecifiedFillColors = (/"gray","gray"/)
res@mpAreaMaskingOn = 1
res@mpMaskAreaSpecifiers = (/"China","Taiwan"/)
;
; Set up some map resources.
;
;nc1 = NhlNewColor(wks,.7,.7,.7) ; Add light gray to colormap,
; for continents.
res = True
res@gsnMaximize = True ; Maximize plot in frame.
res@gsnFrame = False ; Don't advance the frame
res@mpDataSetName = "Earth..4" ; This new database contains
; divisions for other countries.
res@mpDataBaseVersion = "MediumRes" ; Medium resolution database
res@mpOutlineOn = True ; Turn on map outlines
res@mpOutlineSpecifiers = (/"China:states","Taiwan"/) ;China:states
res@mpGeophysicalLineThicknessF= 2. ; double the thickness of geophysical boundaries
res@mpNationalLineThicknessF= 2. ; double the thickness of national boundaries
;
; Zoom in on P. R. China.
;
res@mpMinLatF = 17.
res@mpMaxLatF = 55.
res@mpMinLonF = 72.
res@mpMaxLonF = 136.
;res@mpFillColors = (/-1,-1,nc1,-1/) ;assign light gray to land masses
res@mpFillColors = (/"transparent","transparent","transparent","transparent"/) ;fill land and ocean in transparent
res@cnInfoLabelOn = False ;Don't draw an informational label
plot = gsn_csm_contour_map_ce(wks,blh0utc6step_ave_lesscwyear_anomaly(:,:), res) ; create plot
******************************************************************************************************
Wen.J.Qu
2014-03-27
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
--
______________________________________________________________
Adam Phillips asphilli@ucar.edu
NCAR/Climate and Global Dynamics Division (303) 497-1726
P.O. Box 3000
Boulder, CO 80307-3000 http://www.cgd.ucar.edu/staff/asphilli
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
This archive was generated by hypermail 2.1.8 : Mon Mar 31 2014 - 11:47:09 MDT