begin a=addfile("HP_Temp.nc","r") tmean=a->tmean(:,0,0) tmin=a->tmin(:,0,0) tmax=a->tmax(:,0,0) ; read in right variable (y2) tmean_time=a->time(0:66) ; this is our x ;---Convert to fractional years for easier plotting. time=cd_calendar(tmean_time,4) ; scale for convenience ;---Start the graphics wks = gsn_open_wks("png","xy") ; send graphics to PNG file ;---Plotting options for time series plot res = True res@gsnMaximize = True res@gsnDraw = False ; Will draw later, after overlaying res@gsnFrame = False ; all plots res@vpWidthF = 0.8 ; Make plots wider res@vpHeightF = 0.4 ;---Resources for legend res@pmLegendDisplayMode = "Always" ; turn on legend res@pmLegendWidthF = 0.12 ; Change width and res@pmLegendHeightF = 0.15 ; height of legend. res@pmLegendOrthogonalPosF = -0.08 ; move up slightly res@lgLabelFontHeightF = .011 ; change font height res@lgPerimOn = False ; no box around res@lgItemOrder = (/1,0/) ; reverse legend ;---Titles res@tiMainString = "Temperature" res@tiYAxisString = "Temp in Deg Celsius" ;---Turn off some tickmarks res@tmXTOn = False ; bottom off res@tmYROn = False ; right off res@xyLineThicknessF = 2.0 ; default is 1 res@xyMonoDashPattern = True ; force all solid lines ;-------------------------------------------------- ; The time_axis_label function adds additional ; resources to "res" to produce nicely-formatted ; time labels on X axis. This function only works ; if you have a time "units" recognized by the ; cd_calendar function. ;--------------------------------------------------- ;---Set resources for colors and labels colors1 = (/"blue","red"/) colors2 = (/"darkgreen","darkorange"/) colors3 = (/"brown","purple"/) labels1 = "Tmean" labels2 = "Tmax" labels3 = "Tmin" ;---Create the four XY plots res@xyLineColors = colors1 res@xyExplicitLegendLabels = labels1 res@pmLegendParallelPosF = 0.15 plot1 = gsn_csm_xy(wks,time,tmean,res) res@xyLineColors = colors2 res@xyExplicitLegendLabels = labels2 res@pmLegendParallelPosF = 0.37 plot2 = gsn_csm_xy(wks,time,tmax,res) res@xyLineColors = colors3 res@xyExplicitLegendLabels = labels3 res@pmLegendParallelPosF = 0.59 plot3 = gsn_csm_xy(wks,time,tmax,res) ;---Overlay one plot on the other, so they become one plot. overlay(plot1,plot2) overlay(plot1,plot3) draw(plot1) ; This will draw all four plots frame(wks) end