;---Create dummy time array function create_time_array(begin_year,end_year) local units, years, nyears, num_days, ny, nm begin years = ispan(begin_year,end_year,1) nyears = dimsizes(years) time = ispan(0,(nyears*12)-1,1) time@units = "months since 2004-01-01" return(time) end function create_dummy_array() begin ystart = 2004 yend = 2014 time = create_time_array(ystart,yend) ydum = random_uniform(-5.,10.,(yend-ystart+1)*12); create random 1D array ydum!0 = "time" ydum&time = time return(ydum) end function get_xaxis_values_and_labels(time) begin ;---Reverse engineer the time array to get back year, month, day, etc dates = cd_calendar(time,0) ; n x 6 array years = toint(dates(:,0)) months = toint(dates(:,1)) days = toint(dates(:,2)) ;---Start constructing the strings for the X axis labels month_vals = (/ 3, 6, 9, 12/) ; months where we want labels season_strs = (/"MAM","JJA","SON","DJF"/) + "~C~" ; ~C~ is a carriage return ;---Get the indexes for the first day of the month for the first month of each season ii = ind(months.eq.3.or.months.eq.6.or.months.eq.9.or.months.eq.12.and.days.eq.1) nii = dimsizes(ii) xaxis_labels = new(nii,string) do n=0,dimsizes(month_vals)-1 xaxis_labels = where(months(ii).eq.month_vals(n),season_strs(n)+years(ii),xaxis_labels) end do return([/time(ii),xaxis_labels/]) end begin y = create_dummy_array() wks = gsn_open_wks("x11","xy") res = True res@gsnMaximize = True ; maximize plot in frame res@vpWidthF = 0.8 ; make plot wider than it is high res@vpHeightF = 0.3 res@trYMinF = min(y) res@trXMinF = min(y&time) res@trXMaxF = max(y&time) plot = gsn_csm_xy(wks,y&time,y,res) ; plot with default labels alist = get_xaxis_values_and_labels(y&time) ; [/values, labels/] res@tmXBMode = "Explicit" res@tmXBValues = alist[0](::3) ; only label every 3rd season res@tmXBLabels = alist[1](::3) res@tmXBLabelFontHeightF = 0.012 plot = gsn_csm_xy(wks,y&time,y,res) end