Dear all,
I have a panel with big white place bewteent the plot, I tried the to set
resP@gsnPanelYWhiteSpacePercent =0.0
resP@gsnPanelXWhiteSpacePercent =0.0,
And it seems no changing.
Another strange thing is that my XBLabels can not write on the figure even when I set
res@tmXBMode = "Explicit"
res@tmXBValues = (/1,31,62,93,121,151/)
res@tmXBLabels = (/"","N","D","J","F","M"/).
To show my trouble, I attached the figure (index.panel.pdf) behind my letter.
Also, I attached the scripts in the following.
Any suggestiong is appriciated!
;*******************************************
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"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
;*******************************************
undef("sub_draw")
function sub_draw(wks,xaxis,index,it)
local wks,res,index,plot,xaxis,it
begin
res = True ; plot mods desired
res = True ; plot mods desired
res@gsnFrame = False ; don't draw yet
res@gsnDraw = False ; don't advance yet
res@tiYAxisString = " " ; add units to title
res@tfPolyDrawOrder = "Predraw" ; put line on top
res@gsnLeftString ="";ti ; title
res@gsnRightString = ""
res@tiMainString = ""
res@tiMainOn = True ; False ;True ;False
res@tiXAxisOn = False
res@tiXAxisOn = False
res@tmXBLabelsOn = False
res@tmYROn = False
res@tmYLOn = False
res@tmXBOn = False
res@tmXTOn = False
if( mod(it,3) .eq. 0 ) then
res@tiYAxisOn = True
res@tmYLOn = True
res@tmYLFormat = "f"
res@tmYLMinorPerMajor = 1
res@tmYLMinorOn = False
res@tmYLLabelStride =2
end if
if( it .eq. 30 .or. it .eq. 31 .or. it .eq. 32) then
print("it="+it)
res@tmXBOn = True
res@tiXAxisOn = True
;res@tmXBLabels = True
;res@tmXBFormat = "f"
;delete(xaxis@long_name)
res@tmXBMode = "Explicit"
res@tmXBValues = (/1,31,62,93,121,151/)
res@tmXBLabels = (/"","N","D","J","F","M"/)
;res@tmXBMinorValues = ispan(1949,2006,1)
end if
res@vpHeightF= 0.3 ; change aspect ratio of plot
res@vpWidthF = 0.8
res@vpXF = 0.1 ; start plot at x ndc coord
res@trYMinF = -5 ; min value on y-axis
res@trYMaxF = 5 ; max value on y-axis
res@gsnYRefLine = (/0.0, 1.066494*2, -1.066494*2/) ; create a reference line
res@gsnYRefLineDashPatterns= (/0,2,2/)
res@gsnPaperOrientation = "portrait"
;-------------------------------------------
res@xyLineColors = "foreground" ; line colors
res@xyLineThicknessF = 1.5 ; line thicknesses
res@xyDashPattern = 0 ; keep all solid
nt = dimsizes(xaxis)
res@trXMinF = xaxis(0)
res@trXMaxF = xaxis(nt-1)
plot = gsn_csm_xy(wks,xaxis,index,res) ; create plot
return(plot)
end
;*******************************************
undef("sub_draw_add")
function sub_draw_add(wks,plot,xp,yp)
local wks,plot,xp,yp,dummy
begin
;
; hight the line use p
;
gsres = True ; poly res
;gsres@gsLineColor = "red"
gsres@gsFillColor = "Salmon" ; color chosen
gsres@gsLineThicknessF = 4
gsres@tfPolyDrawOrder = "Postdraw"
;dum = gsn_add_polyline(wks,plot,xp,yp,gsres) ; draw polygon
dum = gsn_add_polygon(wks,plot,xp,yp,gsres) ; draw polygon
dname = unique_string("dum")
plot@$dname$ = dum
return(plot)
end
;*******************************************
begin
inf0 = "nami.49-04.11-3.5-30.grd" ; index file 56*151 ,11.1-3.31
infp = "check_5-30.p.txt"
infn = "check_5-30.n.txt"
iyr0 = 1949
iyr1 = 2004
nyrs = iyr1-iyr0+1
nd = 151
nt = nyrs*nd
ceri = 1.066494*2.0
;
; read in index file
;......
nrec = 0
dims = (/nyrs,nd/)
index = fbindirread(inf0, nrec, dims, "float")
;
; asign the meta data
;
year = ispan(iyr0,iyr1,1)
year!0 = "year"
year&year = year
day = ispan(1,151,1)
day!0 = "day"
day&day = day
index!0 = "year"
index&year = year
index!1 = "day"
index&day = day
printVarSummary(index)
;
; read in ascii file
;......
;
;1). year bands start_loc length phase0 phase1 phase2 phase3 phase4
;......
datep = asciiread(infp,(/142,9/),"float")
;print(datep(0:1,:)) ; Print the values
;2). year bands start_loc length phase4 phase5 phase6 phase7 phase8
;......
daten = asciiread(infn,(/119,9/),"float")
;print(daten(0:1,:)) ; Print the values
;
; draw plot
;
outname = "./tu/index.panel"
wks = gsn_open_wks("pdf",outname)
xaxis = ispan(1,151,1)
plot = new(nyrs,graphic)
do iy=iyr0,iyr1
;outname = "./tu/"+iy+".index"
;wks = gsn_open_wks("eps",outname)
;xaxis = ispan(1,151,1)
;plot = new(nyrs,graphic)
it=iy-iyr0
plot(iy-iyr0)=sub_draw(wks,xaxis,index({year|iy},day|:),it)
do i=0,142-1
if( datep(i,0) .eq. iy ) then
st = floattointeger( ceil (datep(i,4)) ) ; Computes the smallest integer value larger than the input
ed = floattointeger( floor(datep(i,8)) ) ; Computes the largest integer value smaller than the input
if(st .eq. 0 ) then
st =1
end if
if(ed .eq. 152) then
ed =151
end if
xp = ispan ( st,ed,1)*1. ; the x cordinate of added polyline
np = dimsizes(xp) ;ed-st+1
yp = index({year|iy},{day|st:ed})
xpp = new(np+2,float)
xpp(1:np) = xp(0:np-1)
xpp(0) = datep(i,4)
xpp(np+1) = datep(i,8)
ypp= new(np+2,float)
ypp(1:np) = yp(0:np-1)
ypp(0) = 0
ypp(np+1)=0
plot(iy-iyr0) = sub_draw_add(wks,plot(iy-iyr0),xpp,ypp)
delete(xp)
delete(yp)
delete(np)
delete(xpp)
delete(ypp)
delete(st)
delete(ed)
end if
end do
do j=0,119-1
if( daten(j,0) .eq. iy ) then
st = floattointeger( ceil (daten(j,4)) ) ; Computes the smallest integer value larger than the input
ed = floattointeger( floor(daten(j,8)) ) ; Computes the largest integer value smaller than the input
if(st .eq. 0 ) then
st =1
end if
if(ed .eq. 152) then
ed =151
end if
xp = ispan ( st,ed,1)*1. ; the x cordinate of added polyline
np = dimsizes(xp) ;ed-st+1
yp = index({year|iy},{day|st:ed})
xpp = new(np+2,float)
xpp(1:np) = xp(0:np-1)
xpp(0) = daten(j,4)
xpp(np+1) = daten(j,8)
ypp= new(np+2,float)
ypp(1:np) = yp(0:np-1)
ypp(0) = 0
ypp(np+1)=0
plot(iy-iyr0) = sub_draw_add(wks,plot(iy-iyr0),xpp,ypp)
delete(xp)
delete(yp)
delete(np)
delete(xpp)
delete(ypp)
delete(st)
delete(ed)
end if
end do
end do
;draw(plot(iy-iyr0))
;frame(wks)
resP = True
resP@gsnMaximize = True
resP@gsnPaperOrientation = "portrait"
resP@gsnPanelFigureStrings= ispan(iyr0,iyr1,1)
resP@gsnPanelFigureStringsFontHeightF = 0.008
resP@amJust = "TopRight"
resP@amOrthogonalPosF = -0.47
resP@amParallelPosF = 0.45
resP@gsnPanelFigureStringsBackgroundFillColor ="transparent"
resP@gsnPanelFigureStringsPerimOn = False
resP@gsnPanelBottom = 0.05
resP@gsnPanelYWhiteSpacePercent =0.0
resP@gsnPanelXWhiteSpacePercent =0.0
gsn_panel(wks,plot(0:32),(/11,3/),resP)
return
end
_______________________________________________
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 : Wed Apr 14 2010 - 09:15:22 MDT