[R] fill in area between 2 lines with a color

2008-07-20 Thread David Freedman
Hi - I'd like to have the area between 2 lines on a x-y plot be filled with grey, but I haven't had any luck using polygon or rect. (In reality, I'd like to do this for twice - once for a low group and once for a high group - and then I'd like to plot a set of data points for a 'normal' group

Re: [R] fill in area between 2 lines with a color

2008-07-20 Thread Dimitris Rizopoulos
try the following: age - 1:10 y.low - rnorm(length(age), 150, 25) + 10*age y.high - rnorm(length(age), 250, 25) + 10*age plot(age,y.high,type = 'n', ylim = c(100, 400), ylab = 'Y Range', xlab = 'Age (years)') lines(age, y.low, col = 'grey') lines(age, y.high, col = 'grey') polygon(c(age,

Re: [R] fill in area between 2 lines with a color

2008-07-20 Thread Marc Schwartz
on 07/20/2008 11:34 AM David Freedman wrote: Hi - I'd like to have the area between 2 lines on a x-y plot be filled with grey, but I haven't had any luck using polygon or rect. (In reality, I'd like to do this for twice - once for a low group and once for a high group - and then I'd like to