# graph of a (three) piece-wise function f(x): f(x)=x when
# x is in [0,1], f(x)=x/2+0.5 when x is in [1,2], and (x^2-1)/2
# when x is in [2,3].
# You can call the file that contents these codes whatever you
# want, say, example.s (I use extension .s to mean a splus program).
# You then can run this program under splus prompt ">" (Of course,
# you have to activate  splus first). Then just type
# source("example.s") after splus prompt ">". Then you will have
# a ps file that contains the graph for the above function.
# Note that usually we run splus codes interactively, especially
# for a small task.
# Be aware that splus is case-sensitive!
# Here the sign "#" means comment
 
  postscript(file="example.ps", horizontal = F,
    height=6, width=8.5, font=3, pointsize=14)
 # par(mfrow=c(1,2))

  x <- seq(0, 1, length=50)
  fx <- x
  plot(x, fx, xlab="x", ylab="f(x)", xlim=c(0,3), ylim=c(0,4), type="l")
  x <- seq(1, 2, length=50)
  fx <- x/2 + 0.5
  lines(x, fx, lty=1)
  x <- seq(2, 3, length=50)
  fx <- (x^2-1)/2
  lines(x, fx, lty=1)
  title("A three piece-wise function", cex=0.9)
  # you can "cex=" to control the size of the title
  dev.off()