Re: problem with explicit x-axis time labeling

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Apr 14 2014 - 13:01:27 MDT

Hi Kerrie,

Generally, if you are trying to use the "Explicit" mode to label any axes, and the labels are not showing up, it's because the values you are using for tmXBValues are not within range of your actual X values.

Your X values are "xvals", but you are using "subsettime" as the locations for the X axis tickmarks. It looks like "xvals" is simply numbers from 0 to N, which I'm guessing is not your actual time values.

Instead of using "xvals" in the call to gsn_csm_xy2, I suggest using the actual time values, if they are numeric values. I'm guessing you could actually use "subsettime":

> plot=gsn_csm_xy2(wks,subsettime,varN(monthind),varUA(monthind),res,False)

--Mary

On Apr 6, 2014, at 12:17 AM, Kerrie Geil <kgeil@email.arizona.edu> wrote:

> Can anyone help me figure out why my x-axis time labels won't appear? I am reading in 5 months of hourly model output and the plots I want to make will display 1 month of hourly output for each loop pass with tickmark labels on the "00" hour of each day. I've tried gsn_csm_y and gsn_csm_xy2, but I get no tick marks on the XB axis and no labels either. Also, there is no error message produced. I've included a portion of my code below. I'm using NCL v 6.1.2. Any suggestions?
>
> Thanks for the help.
>
> ...
>
> ;##### READ TIME AND CONVERT TO INTEGER YYYYMMDDHH FORMAT #####
> time=timefile->XTIME
> time@units="minutes since "+date
> time:=cd_calendar(time,-3)
> ntimes=dimsizes(time)
> nmonths=5
>
> wks = gsn_open_wks(type ,"plots/test")
>
> do iyear=0,0
> do ivar=0,nvars-1
> ;##### GET TIMESERIES FOR VARIABLES AT 1 LOCATION #####
> infileN:=addfile(path+"Noah/"+variables(ivar)+"_Noah_"+years(iyear)+".nc","r")
> infileUA:=addfile(path+"NoahUA/"+variables(ivar)+"_NoahUA_"+years(iyear)+".nc","r")
>
> varN=infileN->$variables(ivar)$(:,Y,X)
> varUA=infileUA->$variables(ivar)$(:,Y,X)
>
> ;##### PLOT EACH MONTH SEPARATELY #####
> do imonth=0,nmonths-1
> ;##### IDENTIFY INDICES FOR 1 MONTH AT A TIME ####
> monthind:=ind( str_get_cols(tostring(time),4,5) .eq. ("0"+tostring(imonth+1)) ) ;### indices of all times in 1 month
> dimtimes=dimsizes(monthind)
>
> ;##### TO BE USED FOR tmXBLabels AND tmXBValues #####
> labels:=tostring(time(monthind))
> subsettime:=time(monthind)
>
> ;##### DEFINE PLOT RESOURCES #####
> res=True
> res@gsnMaximize=True
> res@vpHeightF=0.6
> res@vpWidthF=1.5
> res@xyLineColors=(/"blue","red"/)
> res@gsnLeftString=variables(ivar)
> res@gsnCenterString=varN@description
> res@gsnRightString=varN@units
> res@tiYAxisString=variables(ivar)
> res@tiXAxisString="Time"
>
> res@tmXBMode="Explicit"
> res@tmXBLabelAngleF=270.
> res@tmXBLabelJust="centerLeft"
> res@tmXBValues:=subsettime(0::24)
> res@tmXBLabels:= labels(0::24)
>
> ;##### PLOT USING TWO DIFFERENT PLOTTING FUNCTIONS #####
> plot=gsn_csm_y(wks,(/varN(monthind),varUA(monthind)/),res)
>
> xvals:=ispan(0,dimtimes-1,1)
> plot=gsn_csm_xy2(wks,xvals,varN(monthind),varUA(monthind),res,False)
>
> end do ;### MONTH LOOP ###
> end do ;### VAR LOOP ###
> end do ;### YEAR LOOP ###
>
> ...
>
> --
> Kerrie Geil
>
> Department of Atmospheric Sciences
> University of Arizona
> PAS Building Rm 576
> 1118 E 4th Street
> Tucson, AZ 85721
>
> _______________________________________________
> 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 Apr 14 13:01:40 2014

This archive was generated by hypermail 2.1.8 : Tue Apr 15 2014 - 10:45:19 MDT