#  This script plots an exponential density, with some portion filled. 

#  Set axes parameters to allow us to specify them exactly.  
#  Otherwise, R slightly enlarges plot windows.
par(xaxs = "i")
par(yaxs = "i")

#  Set other graphing parameters.
line.width <- 2

x.values <- seq(from = 0, to = 5, by = 0.01)
plot(x.values, dexp(x.values),
     type = "l", lwd = line.width,
     ylim = c(0, 1),
     main = "", xlab = "", ylab = "", 
     bty = "n", cex.axis = 1.3)

#  Mark a line at 2.
lines(c(2, 2), c(0, dexp(2)), lwd = line.width)

#  Fill the graph past 2 below the density.  
filled.x.values <- seq(from = 2, to = 5, length.out = 300)
polygon(c(filled.x.values, rev(filled.x.values)), 
        c(rep(0, 300), dexp(rev(filled.x.values))), 
        col = "gray")

dev.print(device = postscript, "3.6.eps", horizontal = TRUE)