#proc page
#if @DEVICE in gif,png
  scale: 0.7
#endif
pagesize: 12 8

#declare BEG, END
#set BEG = "2000/01/01
#set END = "2000/12/31

// read data file
#proc getdata
  file: precip.dat
  delimit: comma
#proc endproc

#proc print
label: @NRECORDS records and @NFIELDS fields

// define top plotting area
#proc areadef
  rectangle: 1 3.5 10 7.5
  title: @TEMP_TITLE
  title2: @YEAR
  title2details: align=R
  xscaletype: date yyyy/mm/dd
  xrange:  @BEG @END
  yrange: 0 110
  frame: yes

// set up X axis
#proc xaxis
  stubs: inc 1 month
  stubformat: Mmm
  stubrange: @BEG @END
  grid: color=skyblue

// set up Y axis
#proc yaxis
  stubs: inc 5
  minortics: yes
  minorticinc: 1
  grid: color=skyblue

#proc yaxis
  location: 10
  stubdetails: adjust=0.5,0.0
  ticlen: 0 0.05
  minorticlen: 0 0.02
  stubs: inc 5
  minortics: yes
  minorticinc: 1
  grid: color=skyblue

// Upper and lower temperature limits
#proc rangesweep
  lofield: 8
  hifield: 7
  xfield: 1
  color: pink


// draw hi/low bars for max/min temperature
#proc bars
  locfield: 1
  segmentfields: 2 3
  thinbarline: color=red

#proc curvefit
  yfield: 5
  xfield: 1
  curvetype: avg
  order: 3
  linedetails: color=black width=0.1

// define bottom plotting area
#proc areadef
  rectangle: 1 1 10 2.75
  title: @PRCP_TITLE
  title2: @YEAR
  title2details: align=R
  xscaletype: date yyyy/mm/dd
  xrange: @BEG @END
  // yrange: 0 @PRCP
  yrange: 0 60
  frame: yes
 
// set up X axis
#proc xaxis
  stubs: inc 1 month
  stubformat: Mmm
  stubrange: @BEG @END
  grid: color=skyblue
  autoyears: yyyy
 
// set up Y axis
#proc yaxis
  stubs: inc 5
  minortics: yes
  minorticinc: 1
  grid: color=skyblue

// draw right axis on prcp plot
#proc yaxis
  location: 10
  stubdetails: adjust=0.5,0.0
  ticlen: 0 0.05
  minorticlen: 0 0.02
  stubs: inc 5
  minortics: yes
  minorticinc: 1
  grid: color=skyblue                                                                                                                  
 
// plot normal accumulated prcp line
#proc lineplot
  yfield: 10
  xfield: 1
  linedetails: color=black width=1.0
  accum: yes
  stairstep: no
  lastx: @END
#proc endproc

// draw accumulated precip line
#proc lineplot
  yfield: 6
  xfield: 1
  linedetails: color=green width=1.5
  accum: yes
  stairstep: yes
  lastx: @END
  gapmissing: yes
#proc endproc

// added scg - display ? for missing precip measurements
#proc scatterplot
  xfield: 1
  ylocation: 3(s)
  select: @@6 like *M*
  text: ?
  textdetails: size=6 color=green