;**************************************************** ; Concepts illustrated: ; - Drawing an XY plot with two different Y axes ; - Changing the title on the Y axis ; - Changing the line dash pattern in an XY plot ; - Changing the line color for multiple curves in an XY plot ; - Setting the mininum/maximum value of the Y axis in an XY plot ; ;**************************************************** ; ; These files are loaded by default in NCL V6.2.0 and newer ; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" ; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" ;**************************************************** begin ;*************************** ; read in data ;*************************** A = addfile("HPRF_1951_2017_JJAS_fldmean.nc","r") B = addfile("HPTmean_1951_2017_JJAS_fldmean.nc","r") C = addfile("HPTmin_1951_2017_JJAS_fldmean.nc","r") D = addfile("HPTmax_1951_2017_JJAS_fldmean.nc","r") ; read in left variable (y1) rf = A->rf tmean = B->t tmin = C->t tmax = D->t ; read in right variable (y2) tmean_time = B->time ; this is our x rf_time = A->time Tdata=new((/3,dimsizes(tmean!time)/),float) Tdata(0,:)=tmin(0,:,:) Tdata(1,:)=tmean(0,:,:) Tdata(2,:)=tmax(0,:,:) ;*************************** ;---Convert to fractional years for easier plotting. ;*************************** Tdata_yfrac = cd_calendar(tmean_time,4) rf_yfrac = cd_calendar(rf_time,4) ;*************************** ;---LOOKING AT THE DATA! ;*************************** printVarSummary(tmean) printVarSummary(tmin) printVarSummary(tmax) printVarSummary(rf) printMinMax(tmean,0) printMinMax(tmin,0) printMinMax(tmax,0) printMinMax(rf,0) printVarSummary(tmean_time) printVarSummary(rf_time) printMinMax(tmean_time,0) printMinMax(rf_time,0) printVarSummary(Tdata_yfrac) printVarSummary(rf_yfrac) printMinMax(Tdata_yfrac,0) printMinMax(rf_yfrac,0) ;*************************** ; plot parameters ;*************************** wks = gsn_open_wks("png","xy") ; send graphics to PNG file ; resources for "left" variable resL = True resL@xyLineThicknesses = 2. ; thicker line resL@tiYAxisString = "Temperature in Deg. Celsius" ; axis string resL@xyLineColors = "red" ; resources for "right" variable resR = True resR@xyDashPatterns = 1 ; dashed line for 2nd resR@xyLineThicknesses = 2 ; thicker line resR@tiYAxisString = "Rainfall in mm" ; axis string resR@xyLineColors = "blue" plot = gsn_csm_x2y2(wks,Tdata_yfrac,rf_yfrac,Tdata,rf,resL,resR) end