Is there a function that can shade the region between two arbitrary curves? For example, how can I fill in the area between these two plotted curves?> x <- 1:10 > y <- x + rnorm(10) > z <- x + 10 + rnorm(10) > plot(x, y, type = "l", ylim = c(0,20)) > lines(x, z)I would appreciate any help. David
Is there a function that can shade the region between two arbitrary curves? For example, how can I fill in the area between these two plotted curves?> x <- 1:10 > y <- x + rnorm(10) > z <- x + 10 + rnorm(10) > plot(x, y, type = "l", ylim = c(0,20)) > lines(x, z)I would appreciate any help. David
Is there a function that can shade the region between two arbitrary curves? For example, how can I fill in the area between these two plotted lines?> x <- 1:10 > y <- x + rnorm(10) > z <- x + 10 + rnorm(10) > plot(x, y, type = "l", ylim = c(0,20)) > lines(x, z)I would appreciate any help. David
On 4 February 2011 at 07:55, David Bickel wrote: | Is there a function that can shade the region between two arbitrary | curves? For example, how can I fill in the area between these two | plotted curves? | | > x <- 1:10 | > y <- x + rnorm(10) | > z <- x + 10 + rnorm(10) | > plot(x, y, type = "l", ylim = c(0,20)) | > lines(x, z) Yes, this can be done using polygon(). For a worked example please see http://dirk.eddelbuettel.com/blog/2011/01/16#overbought_oversold_plot which contains a complete example (for shading plus/minus one and day rolling standard deviations around a rolling mean for financial times series): | I would appreciate any help. Hope this helps. No need to post three times, by the way. Dirk -- Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com