Curve example

The script below, curvefill.pcm, will fill the area under a curve with a solid color, it will fill the area bounded by the curve and a horizontal line through the origin. It expects parameters which are the vector names containing the data, with the independent vector first and the dependent vector second. The third parameter the script expects is the name of the fixed color to use for filling.

  ! curvefill.pcm
  !
  XO = ?1
  YO = ?2
  SET AREAFILLCOLOR STRING(?3)
  L = LEN(XO)
  XO[2:L+1] = XO[1:L]
  XO[L+2] = XO[L+1]
  YO[2:L+1] = YO[1:L]
  YO[1] = 0
  YO[L+2] = 0
  GRAPH XO YO
  ZEROLINES\HORIZONTAL ! draw horizontal line thru (0,0)
  DEFAULTS
 

The following commands generate some data and call curvefill.pcm, producing the figure below.

GENERATE X -5,,5 50
Y=X^2+3*X-2
@CURVEFILL X Y RED

  Numeric vector
  Histogram example