Re: x axis Major Tick Marks

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Nov 11 2013 - 09:43:58 MST

My guess is that your X axis values are not in the same range as the tick mark values you are trying to give it.

If you run the script below, you will see the same error. Part of the problem is because the "x" values go from 1000 to 9000 in steps of 1000, but I'm trying to put tickmarks at locations 1986, 1987, and 1988, which is just a very small fraction of the full range of my X axis.

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"

begin
  x = ispan(1000,9000,1000)
  y = (/0.,0.71,1.,0.7,0.002,-0.71,-1.,-0.71,-0.003/)

  printMinMax(x,0)

  wks = gsn_open_wks("x11","xy")

  res = True
  res@tmXBMode = "Manual"
  res@tmXBTickStartF = 1986
  res@tmXBTickEndF = 1988
  res@tmXBTickSpacingF= 1
  res@tmXBPrecision = 4
  plot = gsn_csm_xy(wks,x,y,res)

end

In your case, your X axis is represented by "yrF" and you are trying to put tickmarks at locations 1986, 1987, and 1988.

I don't know what "yrF" looks like, but it needs to be somewhere near the range 1986-1988, otherwise you won't see any tickmark values.

I'm not sure why you are setting tmXBPrecision. I don't think you need this.

Print out your "yrF" values to see what they look like:

print(yrF)

Please look at your data before posting to ncl-talk, and make sure that what you are plotting is in the range you are expecting.

Use procedures like "print", "printMinMax", and "printVarSummary" to learn more about your data.

Also look over our posting guidelines, as there are suggestions for how find answers on your own without always having to post to ncl-talk:

http://www.ncl.ucar.edu/Support/posting_guidelines.shtml

--Mary

On Nov 10, 2013, at 6:48 PM, Yi-Chih Huang <dscpln@gmail.com> wrote:

> Hello,
>
> I am trying to give 1986, 1987, and 1988 on x axis. But I got the warning below. There is no tick mark or any labeling on x axis. Is there anyone knowing what is wrong with my script?
>
> Thanks much,
>
> Yi-Chih
>
> #####
> yhuang@arc-env:/fs3/yhuang/scripts$ ncl dipoleMth.ncl
> Copyright (C) 1995-2013 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 6.1.2
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> warning:ManualComputeMajorTickMarks: The precision specified is smaller than the precision needed tick mark labels may not be correct
> warning:ManualComputeMajorTickMarks: The precision specified is smaller than the precision needed tick mark labels may not be correct
> warning:ManualComputeMajorTickMarks: The precision specified is smaller than the precision needed tick mark labels may not be correct
> warning:ManualComputeMajorTickMarks: The precision specified is smaller than the precision needed tick mark labels may not be correct
> warning:ManualComputeMajorTickMarks: The precision specified is smaller than the precision needed tick mark labels may not be correct
> warning:ManualComputeMajorTickMarks: The precision specified is smaller than the precision needed tick mark labels may not be correct
> warning:ManualComputeMajorTickMarks: The precision specified is smaller than the precision needed tick mark labels may not be correct
> warning:ManualComputeMajorTickMarks: The precision specified is smaller than the precision needed tick mark labels may not be correct
> warning:ManualComputeMajorTickMarks: The precision specified is smaller than the precision needed tick mark labels may not be correct
> warning:ManualComputeMajorTickMarks: The precision specified is smaller than the precision needed tick mark labels may not be correct
> warning:ManualComputeMajorTickMarks: The precision specified is smaller than the precision needed tick mark labels may not be correct
> warning:ManualComputeMajorTickMarks: The precision specified is smaller than the precision needed tick mark labels may not be correct
>
> #####
> begin
> dirSst= "/fs3/SysE_DB/saji/OISST/Monthly/Mean/"
> dirU= "/fs3/SysE_DB/nmm/CFSR/Monthly/Mean/"
> ; dir2= (/"1981/","1982/","1983/"/)
> dir2= (/"1986/","1987/","1988/"/)
> ; dir2= (/"1996/","1997/","1998/"/)
> mth= (/198601,198602,198603,198604,198605,198606,198607,198608,198609,198610,198611,198612,\
> 198701,198702,198703,198704,198705,198706,198707,198708,198709,198710,198711,198712,\
> 198801,198802,198803,198804,198805,198806,198807,198808,198809,198810,198811,198812/)
> varName= (/"sst","us"/)
> nyr= dimsizes(dir2)
>
> dim= dimsizes(mth)
> yrF= new (dim, float)
> do nd=0,dim-1
> yyyy = mth(nd)/100
> mon = mth(nd)-yyyy*100
> yrF(nd) = yyyy + (mon-1)/12.
> end do
>
> xx= new((/nyr*12/),float,"No_FillValue")
> yy= new((/nyr*12/),float,"No_FillValue")
> zz= new((/nyr*12/),float,"No_FillValue")
>
> do ny= 0,nyr-1
> dir = str_concat(dirSst+dir2(ny))
> fil= systemfunc("cd "+dir+" ; ls sst.nc")
> f= addfile (dir+fil, "r")
> x= f->$varName(0)$
> dims = getfilevardims(f,varName(0))
>
> x1= x($dims(0)$|:,{$dims(1)$|10:-10},{$dims(2)$|50:70}) ; first domain
> xs= dim_avg_n_Wrap( x1, (/1,2/) )
>
> y1= x($dims(0)$|:,{$dims(1)$|0:-10},{$dims(2)$|110:90}) ; second domain
> ys= dim_avg_n_Wrap( y1, (/1,2/) )
>
> do i= 0,11
> m= ny*12 +i
> xx(m)= xs(i)
> yy(m)= ys(i)
> end do
> end do
>
> dt= xx - yy
> dt= dim_standardize(dt, 0)
>
> do ny= 0,nyr-1
> dir = str_concat(dirU+dir2(ny))
> fil= systemfunc("cd "+dir+" ; ls us.nc")
> f= addfile (dir+fil, "r")
> y= f->$varName(1)$
> dims = getfilevardims(f,varName(1))
>
> y1:= y($dims(0)$|:,{$dims(1)$|5:-5},{$dims(2)$|70:90})
> ys= dim_avg_n_Wrap( y1, (/1,2/) )
>
> z1:= y($dims(0)$|:,{$dims(1)$|5:-5},{$dims(2)$|:})
> zs= dim_avg_n_Wrap( z1, (/1,2/) )
>
> do i= 0,11
> m= ny*12 +i
> yy(m)= ys(i)
> zz(m)= zs(i)
> end do
> end do
>
> du= yy - zz
> du= dim_standardize(du, 0)
>
> wks = gsn_open_wks ("X11", "dipoleMth87" )
> res = True
> res@gsnScale = True
>
> ; these four resources allow the user to stretch the plot size, and
> ; decide exactly where on the page to draw it.
>
> res@vpXF = 0.10 ; In page coordinates, where to start
> res@vpYF = 0.75 ; the plot
> res@vpHeightF = 0.43 ; Changes the aspect ratio
> res@vpWidthF = 0.85
>
> res@trYMinF = -3.0 ; min value on y-axis
> res@trYMaxF = 3.0 ; max value on y-axis
>
> res@tiYAxisString = "Anomalies" ; y-axis label
> ; res@tiMainString = "Dipole Mode Index and
>
> res@gsnYRefLine = 0. ; reference line
> res@gsnXYBarChart = True ; create bar chart
> res@gsnXYBarChartColors2 = (/"blue"/)
>
> res@tmXBMode = "Manual"
> res@tmXBTickStartF = 1986
> res@tmXBTickEndF = 1988
> res@tmXBTickSpacingF= 1
> res@tmXBPrecision = 4
>
> res@gsnDraw = False
> res@gsnFrame = False
>
> plot1= gsn_csm_xy (wks,yrF,dt,res)
> res@gsnXYBarChartColors2 =(/"red"/)
> plot2= gsn_csm_xy (wks,yrF,du,res)
>
> lbres = True
> lbres@vpWidthF = 0.2 ; labelbar width
> lbres@vpHeightF = 0.1 ; labelbar height
> lbres@lbBoxMajorExtentF = 0.36 ; puts space between color boxes
> lbres@lbFillColors = (/"blue","red"/)
> lbres@lbMonoFillPattern = True ; Solid fill pattern
> lbres@lbLabelFontHeightF = 0.020 ; font height. default is small
> lbres@lbLabelJust = "CenterLeft" ; left justify labels
> lbres@lbPerimOn = False
> lbres@lgPerimColor = "white"
> labels = (/"Dipole Mode Index","Equitorial Zonal Wind Anomaly"/)
> gsn_labelbar_ndc(wks,2,labels,0.10,0.25,lbres) ; draw right labelbar column
>
> overlay(plot1,plot2)
> maximize_output(wks,True)
> frame(wks)
> end
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Nov 11 09:44:08 2013

This archive was generated by hypermail 2.1.8 : Mon Nov 11 2013 - 09:45:33 MST