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

From: David Freedman <3.14david_at_gmail.com>
Date: Sun, 20 Jul 2008 09:34:37 -0700 (PDT)

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 together with these 2 grey areas.)

Here's a simple example of the 2 lines:      

plot(age,y.high,type='n',ylim=c(100,400),ylab='Y Range',xlab='Age (years)') lines(age,y.low,col='grey')

Is it possible to fill the area between the 2 lines filled with, for example, 'grey30' ?

thanks very much in advance,
David Freedman

David Freedman
View this message in context: http://www.nabble.com/fill-in-area-between-2-lines-with-a-color-tp18556096p18556096.html
Sent from the R help mailing list archive at Nabble.com.

R-help_at_r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Sun 20 Jul 2008 - 16:37:49 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 20 Jul 2008 - 17:31:58 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive