load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" begin ;---Specify the input data. xi = (/ 0.00, 2.00, 5.00, 8.00, 10.00, 13.00, \ 15.00, 18.00, 21.00, 23.00, 30.00 /) yi = (/ 1.00, 0.81, 0.00, -0.81, -1.00, -0.84, \ -0.56, 0.04, 0.73, 1.18, 2.0 /) ;---Create the output X coordinate array. npts = 201 xo = fspan(0.,30.,npts) ;---Create smoothed array using different smoothing factors sigs = (/1.,5.,10.,20./) nsigs = dimsizes(sigs) yo = new((/nsigs,npts/),float) do i=0,nsigs-1 ftsetp("sig",sigs(i)) yo(i,:) = ftcurv(xi, yi, xo) end do ;---Start the graphics wks = gsn_open_wks("x11","interp1d") res = True res@gsnMaximize = True res@gsnDraw = False res@gsnFrame = False res@trXMinF = -1 res@trXMaxF = 31 res@trYMinF = -1.1 res@trYMaxF = 2.1 do i=0,nsigs-1 res@tiMainString = "black line is original curve, sig = " + sigs(i) res@xyLineThicknessF = 10. res@xyLineColor = "black" plot_base = gsn_csm_xy(wks,xi,yi,res) res@xyLineThicknessF = 5 res@xyLineColor = "red" plot_ovrly = gsn_csm_xy(wks,xo,yo(i,:),res) overlay(plot_base,plot_ovrly) draw(plot_base) frame(wks) end do end