begin ; ; Create three curves of sightly different lengths. ; Use random_uniform to generate dummy values from 0 to 100. ; npts1 = 10 npts2 = 15 npts3 = 18 x1 = fspan(1,75,npts1) x2 = fspan(1,71,npts2) x3 = fspan(1,73,npts3) y1 = random_uniform(0,100,npts1) y2 = random_uniform(0,100,npts2) y3 = random_uniform(0,100,npts3) wks = gsn_open_wks ("png","xy_overlay") col1 = "red" col2 = "forestgreen" col3 = "navyblue" ;---Set resources common to all three plots res = True res@xyLineThicknessF = 3. ; so we can see lines better ;---Create two of the individual plots that will later become the "overlay" plots. res@xyLineColor = col1 plot1 = gsn_csm_xy (wks,x1,y1,res) res@xyLineColor = col2 plot2 = gsn_csm_xy (wks,x2,y2,res) ;---Set a title for plot3, which will become our "base" plot. res@xyLineColor = col3 res@tiMainString = "line1 = " + col1 + ", line2 = " + col2 + ", line3 = " + col3 plot3 = gsn_csm_xy (wks,x3,y3,res) ;--Overlay plot1 and plot2 on plot3 overlay(plot3,plot1) ; plot1 becomes part of plot3 overlay(plot3,plot2) ; plot2 becomes part of plot3 draw(plot3) ; This will draw all three plots, using plot3 as the base. frame(wks) end