Skip to content
Prev 1651 / 15274 Next

Bloomberg

On Thu, Aug 23, 2007 at 10:38:00PM +0200, Thomas Steiner wrote:
This approach does give a good pure R solution doesn't it? e.g. something like

gradient.under.graph <- function(n=100, y0=0, mu=-0.7, sd=1, nrects=1000) {
    y <- y0 + cumsum(rnorm(n, mean=mu, sd=sd))
    plot(NA, xlim=c(1,n), ylim=range(y), bty="n")
    col <- colorRampPalette(colors=c("dark blue","light blue"))(nrects)
    incr <- (max(y) - min(y)) / nrects
    rect(0, seq(min(y), max(y)-incr, length=nrects), n, seq(min(y)+incr, max(y), length=nrects), col=col, border=NA)
    polygon(x=c(1,1:n,n), y=c(max(y), y, max(y)), col="white", border=NULL)
}

is not slow.

Dan