[ncl-talk] Precipitation annual cycle
Mary Haley
haley at ucar.edu
Tue Feb 13 15:14:41 MST 2018
Hello,
NCL always tries to use "nice" values on the X and Y axis. It will still
plot the data correctly, but you'll get a little bit of a margin.
If you don't want the margin, then use the trX/Y/Min/MaxF resources to
force the actual minimum and/or maximum that you want.
For example, in your case, if you want to set the maximum of the X axis to
the actual maximum of your X array, then set:
res2 at trXMaxF = max(x)
before you call gsn_xy.
By the way, if you want your tickmarks to point outward, you might try
using gsn_csm_xy instead of gsn_xy.
You can see the differences between the gsn_xy and gsn_csm_xy functions by
visiting these two example pages:
gsn_csm_xxx: http://www.ncl.ucar.edu/Applications/xy.shtml
gsn_xxx: http://www.ncl.ucar.edu/Applications/generic_xy.shtml
--Mary
On Mon, Feb 12, 2018 at 10:15 PM, Dinuka Silva <dinu.kera at gmail.com> wrote:
> Hello,
>
> I am trying to plot annual cycle of precipitation. I could plot it but I
> have space after December. how can I remove that space?
>
>
>
>
> 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/diagnostics_cam.ncl"
>
> begin
> ;----------------------------------------------------------------------
> f = "mon.precip.nc"
> f1 = addfile(f, "r")
>
> time = f1->time
> ymd = cd_calendar(time,2)
> iTime = ind (ymd.ge.19790101.and.ymd.lt.20130101)
> precip = f1->precip (iTime,{0:-12},{90:130})
>
> Avg = dim_avg_Wrap(dim_avg_Wrap( precip(time|:,lat|:,lon|:)))
> index = abs(Avg)
> index!0 = "time"
> index&time = Avg&time
> ;------------------------------------------------------------
> T = index&time
> YMD = cd_calendar(T,0)
> imont = tointeger(YMD(:,1))
> ;-----------------------------------------------------------------------
> k= new((/12/),float)
> do mo = 0,11
> mo1=mo+1
> Nmont = ind(imont.eq.mo1)
> k(mo) = dim_avg_Wrap(index(time|Nmont))
> end do
> ;printVarSummary(k)
> ;---------------------------------------------------------------------
> x = new((/12/),float)
> x = (/00.,01.,02.,03.,04.,05.,06.,07.,08.,09.,10.,11./)
> ;--------------------------------------------------------------
> res2 = True
> res2 at tiMainString = "Monthly precipitation"
> res2 at tiXAxisString = "months"
> res2 at tiYAxisString = "precipitation (mm/month)"
> res2 at xyLineColors = "blue"
> res2 at xyLineThicknessF = 5.0
> res2 at tmXBMode = "Explicit"
> res2 at tmXBValues = x
> res2 at tmXBLabels = (/"J","F","M","A","M","J","J","A","S","O","N","D"/)
> ;---------------------------------------------------------------------
> wks = gsn_open_wks("x11","")
> plot = gsn_xy(wks,x,k,res2)
> end
>
>
> [image: Inline image 1]
>
>
> Thank you.
>
> Sincerly,
> Dinuka
>
>
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon> Virus-free.
> www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
> <#m_16324849258779916_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180213/2b3b2075/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 29652 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180213/2b3b2075/attachment.png>
More information about the ncl-talk
mailing list