load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.html"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"

begin

  data = new(4, "float")

  do n = 0, 3

    if(n .eq. 0) then
      fid = addfile("file" + n + ".nc", "r")
    else
      fid = addfile("files" + n + ".nc", "r")
    end if

    x = fid->X

    data(n) = avg(x)

  end do

; Add attributes
  data@long_name = "average value"
  data@units = "unitless"

; Add names to dimensions
  data!0 = "N"
  data&N = ispan(0,3,1)

; Set resources for plot
  res = True
  res@tiMainString = "Simple X-Y plot"
  res@xyMarkLineMode = "Markers"
  res@xyMarker = 16

; Open workspace
  wks = gsn_open_wks("png", "example")

  plot = gsn_csm_xy(wks, data&N, data, res)

end