Hi ncl friends,
I am trying to allocate and plot particular dash pattern in the legend
of my xy plots. But I am unable to control or plot line dash pattern in
the legend. I guess lgDashIndex or lgDashIndexes should be able to
do the trick but for some reason its not working for me. I would
greatly appreciate if somebody could help me to fix this problem.
My ncl code is copied below:
Cheers,
Basit
----------------------
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/wrf/WRFUserARW.ncl"
begin
bh22_h = addfile
("/hpc/bluefern/WRF/basit/basit-archive/b-haze/bh22/wrfout_d03_2006-05-0
6_12:00:00.nc","r")
bh23_h = addfile
("/hpc/bluefern/WRF/basit/basit-archive/b-haze/bh23/wrfout_d03_2006-06-0
4_12:00:00.nc","r")
bh24_b = addfile
("/hpc/bluefern/WRF/basit/basit-archive/b-haze/bh24/wrfout_d03_2007-05-2
6_12:00:00.nc","r")
bh25_nh = addfile
("/hpc/bluefern/WRF/basit/basit-archive/b-haze/bh25/wrfout_d03_2006-06-0
8_12:00:00.nc","r")
bh26_nh = addfile
("/hpc/bluefern/WRF/basit/basit-archive/b-haze/bh26/wrfout_d03_2006-05-2
4_12:00:00.nc","r")
bh27_nh = addfile
("/hpc/bluefern/WRF/basit/basit-archive/b-haze/bh27/wrfout_d03_2006-07-1
4_12:00:00.nc","r")
bh28_h = addfile
("/hpc/bluefern/WRF/basit/basit-archive/b-haze/bh28/wrfout_d03_2001-07-0
2_12:00:00.nc","r")
bh29_h = addfile
("/hpc/bluefern/WRF/basit/basit-archive/b-haze/bh29/wrfout_d03_2002-06-1
4_12:00:00.nc","r")
bh30_h = addfile
("/hpc/bluefern/WRF/basit/basit-archive/b-haze/bh30/wrfout_d03_2006-05-3
0_12:00:00.nc","r")
wks = gsn_open_wks ("x11","timeseries") ; open workstation
pnl_plot = new(4,graphic) ; create a plot array
time = (/58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74/)
time1=
(/106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122/)
time2=
(/154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170/)
time3=
(/202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218/)
hour=time
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pbl_bh22_h = wrf_user_getvar(bh22_h,"PBLH",time)
pbl_bh23_h = wrf_user_getvar(bh23_h,"PBLH",time)
pbl_bh24_nh1 = wrf_user_getvar(bh24_b,"PBLH",time)
pbl_bh24_h1 = wrf_user_getvar(bh24_b,"PBLH",time1)
pbl_bh24_nh2 = wrf_user_getvar(bh24_b,"PBLH",time2)
pbl_bh24_h2 = wrf_user_getvar(bh24_b,"PBLH",time3)
pbl_bh25_nh = wrf_user_getvar(bh25_nh,"PBLH",time)
pbl_bh26_nh = wrf_user_getvar(bh26_nh,"PBLH",time)
pbl_bh27_nh = wrf_user_getvar(bh27_nh,"PBLH",time)
pbl_bh28_h = wrf_user_getvar(bh28_h,"PBLH",time)
pbl_bh29_h = wrf_user_getvar(bh24_b,"PBLH",time)
pbl_bh30_h = wrf_user_getvar(bh30_h,"PBLH",time)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; C A L C U L A T E A V E R A G E PBLH O V E R Auckland D O M A I N
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
istart = 0
iend = 16
pbl_bh22_h_avg = new((/17/),float)
pbl_bh23_h_avg = new((/17/),float)
pbl_bh24_h1_avg = new((/17/),float)
pbl_bh24_nh1_avg = new((/17/),float)
pbl_bh24_h2_avg = new((/17/),float)
pbl_bh24_nh2_avg = new((/17/),float)
pbl_bh25_nh_avg = new((/17/),float)
pbl_bh26_nh_avg = new((/17/),float)
pbl_bh27_nh_avg = new((/17/),float)
pbl_bh28_h_avg = new((/17/),float)
pbl_bh29_h_avg = new((/17/),float)
pbl_bh30_h_avg = new((/17/),float)
do itime = istart,iend
pbl_bh22_h_avg(itime) = avg(pbl_bh22_h(itime,:,:))
pbl_bh23_h_avg(itime) = avg(pbl_bh23_h(itime,:,:))
pbl_bh24_nh1_avg(itime) = avg(pbl_bh24_nh1(itime,:,:))
pbl_bh24_h1_avg(itime) = avg(pbl_bh24_h1(itime,:,:))
pbl_bh24_nh2_avg(itime) = avg(pbl_bh24_nh2(itime,:,:))
pbl_bh24_h2_avg(itime) = avg(pbl_bh24_h2(itime,:,:))
pbl_bh25_nh_avg(itime) = avg(pbl_bh25_nh(itime,:,:))
pbl_bh26_nh_avg(itime) = avg(pbl_bh26_nh(itime,:,:))
pbl_bh27_nh_avg(itime) = avg(pbl_bh27_nh(itime,:,:))
pbl_bh28_h_avg(itime) = avg(pbl_bh28_h(itime,:,:))
pbl_bh29_h_avg(itime) = avg(pbl_bh29_h(itime,:,:))
pbl_bh30_h_avg(itime) = avg(pbl_bh30_h(itime,:,:))
end do
;************************************************
; plotting parameters
;************************************************
res = True ; plot mods desired
res@gsnDraw = False ; Don't draw individual plot
res@gsnFrame = False ; Don't advance frame.
res@tmXTOn = False ; turn off the top tick marks
;res@tmYLMode = "Manual" ; Define own tick mark labels.
res@tmXBMode = "Explicit" ; Define own tick mark labels.
res@tmXBLabelsOn =True
res@tmXBValues =
(/58.,59.,60.,61.,62.,63.,64.,65.,66.,67.,68.,69.,70.,71.,72.,73.,74./)
res@tmXBLabels = (/"5","", "6", "", "7", "", "8", "", "9", "",
"10", "", "11", "", "12", "", "13"/)
res@tmYLMajorOutwardLengthF= 0.0 ; set to 0.0 draw minor ticks
inward
res@tmYLMinorOutwardLengthF= 0.0 ; set to 0.0 draw minor ticks
inward
res@tmXBMajorOutwardLengthF= 0.0 ; set to 0.0 draw minor ticks
inward
res@tmXBMinorOutwardLengthF= 0.0 ; set to 0.0 draw minor ticks
inward
res@tmYLPrecision = 4 ; Control total number of
digits incl. decimals
res@tmXBPrecision = 2 ; Control total number of
digits incl. decimals
res@tiXAxisString = "Hour (NZST)" ; X axes label
res@tmXBTickSpacingF = 2 ; X axis tick marks interval,
only uses with Manual option
res@tmXBMinorPerMajor = 2 ; # of minor tick marks per
major
res@tmYLTickSpacingF = 300 ; Y axis tick marks interval,
only uses with Manual option
res@trYMaxF = 1200 ; X axis max
res@trYMinF = 0
; res@trXMaxF = 16 ; X axis max
; res@trXMinF = 0 ; X axis min
res@tmXBMinorOn = True ; X Minor tick marks is on
res@tmYLMinorOn = True ; X Minor tick marks is on
res@xyLineColor = "Red"
res@vpWidthF = 0.35 ; panel width
res@vpHeightF = 0.39 ; panel height
res@tiYAxisString = "PBL Height (m)" ; (~S~o~N~C)", watts m-2:
(~N~Wm~S~-2~N~)" Y-axis label;
;-----------------------------------------------------------------------
--------
; R E S O U R C E S
;-----------------------------------------------------------------------
----------
res1=res
res1@vpXF = 0.1 ; x location
res1@vpYF = 0.96 ; y location
res1@xyDashPatterns = 0
res2=res1 ; res1 is red color (hd)
res2@xyLineColor = "Blue" ; res2 is blue color(nhd)
res2@xyDashPatterns = 0
res3=res ; res3 is red color (hd)
res3@vpXF = 0.56 ; x location
res3@vpYF = 0.96 ; y location
res4=res3
res4@xyLineColor = "Blue" ; res4 is blue color(nhd)
res5=res ; res5 redcolor hd
res5@vpXF = 0.1 ; x location
res5@vpYF = 0.47 ; y location
res6=res5 ; res6 blue color nhd
res6@xyLineColor = "Blue"
res7=res5 ; res 7 redcolor hd
res7@xyDashPatterns = 16
res8=res ; linecolor for res8 will be red
res8@vpXF = 0.56 ; x location
res8@vpYF = 0.47 ; y location
res9=res8
res9@xyLineColor = "Blue"
res10=res8 ; linecolor will be red
res10@xyDashPatterns = 16
res11=res8 ; linecolor will be blue
res11@xyLineColor = "Blue"
res11@xyDashPatterns = 16
;
------------------------------------------------------------------------
------------------
plot1 = gsn_csm_xy (wks, hour, pbl_bh23_h_avg, res1) ; create plot
plot2 = gsn_csm_xy (wks,hour, pbl_bh25_nh_avg , res2) ; create plot
overlay (plot1 , plot2)
pnl_plot (0) = plot1
plot3 = gsn_csm_xy (wks,hour, pbl_bh22_h_avg , res3) ; create plot
plot4 = gsn_csm_xy (wks,hour, pbl_bh26_nh_avg , res4) ; create plot
overlay (plot3 , plot4)
pnl_plot (1) = plot3
plot5 = gsn_csm_xy (wks,hour, pbl_bh30_h_avg, res5) ; create plot
plot6 = gsn_csm_xy (wks,hour, pbl_bh27_nh_avg, res6) ; create plot
plot7 = gsn_csm_xy (wks,hour, pbl_bh28_h_avg, res7) ; create plot
overlay (plot5 , plot6)
overlay (plot5 , plot7)
pnl_plot (2) = plot5
plot8 = gsn_csm_xy (wks,hour, pbl_bh24_h1_avg , res8) ; create plot
plot9 = gsn_csm_xy (wks,hour, pbl_bh24_nh1_avg , res9) ; create plot
plot10 = gsn_csm_xy (wks,hour, pbl_bh24_h2_avg , res10) ; create plot
plot11 = gsn_csm_xy (wks,hour, pbl_bh24_nh2_avg , res11) ; create plot
overlay(plot8, plot9)
overlay(plot8, plot10)
overlay(plot8, plot11)
pnl_plot (3) = plot8
;***********************************************
; legend resources
;***********************************************
lgres = True
lgres@lgLineColors = (/"Red","Blue"/)
lgres@lgDashIndex = (/0., 16./) ; line paterns
lgres@lgLineLabelStrings = (/"",""/)
lgres@lgLineThicknessF = res@cnLineThicknessF ; legend line
thickness = contour line thickness
lgres@lgItemType = "Lines" ; show lines only (default)
lgres@lgLabelFontHeightF = .14 ; set the legend label font
thickness
lgres@vpWidthF = 0.10 ; width of legend (NDC) -
may also be used to inc. or dec. dist
lgres@vpHeightF = 0.03 ; height of legend (NDC)-
b/w legend rows + font size
lgres@lgPerimColor = "Black" ; draw the box perimeter in
Black
lgres@lgPerimThicknessF = 1.0 ; thicken the box perimeter
; lgres@lgBoxLinesOn = False
lgres@lgPerimOn = False ; don't display preimeter
box around legend
; lgres@pmLegendWidthF = 0.10
; lgres@pmLegendHeightF = 0.10
; lgres@lgLabelFontHeightF= 0.010 ; chane font height
; lgres@@pmLegendDisplayMode = "Always"
; lgres@xyExplicitLegendLabels = (/")
lgres1 = True
lgres1@lgLineColors = (/"Red","Blue","Red"/)
lgres1@lgDashIndex = (/0., 0., 0./) ; line paterns
lgres1@lgLineLabelStrings = (/"","",""/)
lgres1@lgLineThicknessF = res@cnLineThicknessF ; legend line
thickness = contour line thickness
lgres1@lgItemType = "Lines" ; show lines only (default)
lgres1@lgLabelFontHeightF = .14 ; set the legend label font
thickness
lgres1@vpWidthF = 0.10 ; width of legend (NDC) -
may also be used to inc. or dec. dist
lgres1@vpHeightF = 0.04 ; height of legend (NDC)-
b/w legend rows + font size
lgres1@lgPerimColor = "Black" ; draw the box perimeter in
Black
lgres1@lgPerimThicknessF = 1.0 ; thicken the box perimeter
; lgres1@lgBoxLinesOn = False
lgres1@lgPerimOn = False ; don't display preimeter
box around legend
;lgres1@lgLabelFontHeightF= 0.005
lgres2 = True
lgres2@lgLineColors = (/"Blue","Red","Blue","Red"/)
lgres2@lgMonoDashIndex = False
lgres2@lgItemCount = 4
; lgres2@cnLineDashPattern = (/0,0,16,16/)
lgres2@lgDashIndex = (/0,0,16,16/) ; line paterns
lgres2@lgLineLabelStrings = (/"","","",""/)
lgres2@lgLineThicknessF = res@cnLineThicknessF ; legend line
thickness = contour line thickness
lgres2@lgItemType = "Lines" ; show lines only
(default)
lgres2@lgLabelFontHeightF = .14 ; set the legend
label font thickness
lgres2@vpWidthF = 0.10 ; width of legend
(NDC) - may also be used to inc. or dec. dist
lgres2@vpHeightF = 0.05 ; height of legend
(NDC)- b/w legend rows + font size
lgres2@lgPerimColor = "Black" ; draw the box
perimeter in Black
lgres2@lgPerimThicknessF = 1.0 ; thicken the box
perimeter
; lgres2@lgBoxLinesOn = False
lgres2@lgPerimOn = False ; don't display
preimeter box around legend
;lgres2@lgLabelFontHeightF= 0.005
lbid = gsn_create_legend(wks,2,(/" 6-Jun-2006 (HD)"," 10-Jun-2006
(NHD)"/),lgres) ; create legend
amres = True
amres@amParallelPosF = 0.34 ; move
legend to the right
amres@amOrthogonalPosF = -0.43 ; move the legend up
annoid1 = gsn_add_annotation(plot1,lbid,amres) ; add legend to plot
lbid2 = gsn_create_legend(wks,2,(/" 8-May-2006(HD)","
26-May-2006(NHD)"/),lgres) ; create legend
amres2 = True
amres2@amParallelPosF = 0.34 ; move
legend to the right
amres2@amOrthogonalPosF = -0.43 ; move the legend up
annoid2 = gsn_add_annotation(plot3,lbid2,amres2) ; add legend to
plot
lbid3 = gsn_create_legend(wks,3,(/" 1-Jun-2006(HD)","
16-Jul-2006(NHD)"," 4-Jul-2001(HD)"/),lgres1) ; create legend
amres3 = True
amres3@amParallelPosF = 0.34 ; move
legend to the right
amres3@amOrthogonalPosF = -0.43 ; move the legend
up
annoi3 = gsn_add_annotation(plot5,lbid3,amres3) ; add legend to plot
lbid4 =
gsn_create_legend(wks,4,(/"28-May-2006(NHD)","29-May-2006(HD)","30-May-2
006(NHD)","31-May-2006(HD)"/),lgres2) ; create legend
amres4 = True
amres4@amParallelPosF = 0.34 ; move
legend to the right
amres4@amOrthogonalPosF = -0.43 ; move the legend
up
annoid4 = gsn_add_annotation(plot8,lbid4,amres4) ; add legend to
plot
;***********************************************
; Panel the WRF plots
;***********************************************
resP= True
; resP@gsnDraw = False ; Don't draw individual plot
resP@gsnFrame = False ; don't advance panel
plot
resP@gsnPanelLabelBar = True ; time, pbl_bh30_h_avg;
add common colorbar
; resP@gsnPanelBottom = 0.05 ; add space at bottom
resP@gsnMaximize = False ; maximize plots
resP@vpWidthF = 0.36 ; panel width
resP@vpHeightF = 0.36 ; panel height
resP@gsnPanelYWhiteSpacePercent = 6 ; Add white space b/w plots
resP@gsnPanelXWhiteSpacePercent = 6 ; Add white space b/w plots
resP@gsnPanelScalePlotIndex = 1
resP@gsnPanelFigureStrings= (/"a) HNW","b) HE","c) HSE","d) H"/) ; add
strings to panel
resP@amJust = "TopLeft"
res@txFontHeightF = .24
gsn_panel(wks,pnl_plot,(/2,2/),resP) ; now draw as one
plot
frame(wks)
end
This email may be confidential and subject to legal privilege, it may
not reflect the views of the University of Canterbury, and it is not
guaranteed to be virus free. If you are not an intended recipient,
please notify the sender immediately and erase all copies of the message
and any attachments.
Please refer to http://www.canterbury.ac.nz/emaildisclaimer for more
information.
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Feb 7 21:48:53 2011
This archive was generated by hypermail 2.1.8 : Fri Feb 11 2011 - 16:11:42 MST