load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" begin ;---Define the number of points in each curve. NPTS = 500 PI100 = 0.031415926535898 theta = PI100*ispan(0,NPTS-1,1) ;---Create 4 dummy curves. NCURVES = 4 y = new((/NCURVES,NPTS/),float) do i=0,NCURVES-1 y(i,:) = sin((i+1)*sqrt(fabs(theta))) end do ;---Space the curves out a little. y(2,:) = 2 + y(2,:) y(3,:) = 2 + y(3,:) wks = gsn_open_wks("png","xy") res = True ; Plot options desired res@gsnMaximize = True ; Maximize plot in frame res@trYMinF = -2 ; Leave a margin for legend ;---Make legend smaller and move into plot res@pmLegendOrthogonalPosF = -0.33 res@pmLegendParallelPosF = 0.1 res@pmLegendDisplayMode = "Always" res@pmLegendWidthF = 0.1 res@pmLegendHeightF = 0.1 ;---No spaces in legend label res@xyExplicitLegendLabels = "y" + ispan(1,NCURVES,1) res@tiMainString = "Legend label without spaces" xy = gsn_csm_y(wks,y,res) ;---Spaces in legend label res@pmLegendWidthF = 0.2 ; Need to make this wider res@pmLegendParallelPosF = 0.2 res@xyExplicitLegendLabels = " y" + ispan(1,NCURVES,1) res@tiMainString = "Legend label with spaces" xy = gsn_csm_y(wks,y,res) end