Please, how to fill the area under the curve? x <- c(1:10) y <- c(rnorm(10)) plot(x,y) lines(x,y) Thanks, Mauricio Cardeal
filling the area
8 messages · Benilton Carvalho, Mario Cortina Borja, Carlos Mauricio Cardeal Mendes +2 more
take a look at: ?polygon b
On Jan 25, 2007, at 8:18 AM, Mauricio Cardeal wrote:
Please, how to fill the area under the curve? x <- c(1:10) y <- c(rnorm(10)) plot(x,y) lines(x,y) Thanks, Mauricio Cardeal
Ok. I?ve tried before and all I got was a polygon indeed with the extremes points connected. Please where is the error ? polygon(x,y,col="gray", border = "red") Benilton Carvalho escreveu:
take a look at: ?polygon b On Jan 25, 2007, at 8:18 AM, Mauricio Cardeal wrote:
Please, how to fill the area under the curve? x <- c(1:10) y <- c(rnorm(10)) plot(x,y) lines(x,y) Thanks, Mauricio Cardeal
__________ NOD32 1.1752 (20060912) Information __________ This message was checked by NOD32 antivirus system. http://www.nod32.com
On Thu, 2007-01-25 at 10:18 -0300, Mauricio Cardeal wrote:
Please, how to fill the area under the curve? x <- c(1:10) y <- c(rnorm(10)) plot(x,y) lines(x,y) Thanks, Mauricio Cardeal
See ?polygon x <- 1:10 y <- rnorm(10) plot(x,y, type = "o") polygon(c(min(x), x, max(x)), c(min(y), y, min(y)), col = "blue") HTH, Marc Schwartz
Hi Mauricio, Try: plot(x,y); lines(x,y) polygon( c(min(x), x, max(x)), c( min(y), y, min(y)), density=100 ) Best wishes, Mario Dr Mario Cortina Borja Senior Lecturer in Statistics Centre for Paediatric Epidemiology and Biostatistics Institute of Child Health, University College London M.Cortina at ich.ucl.ac.uk Tel - 020 7905 2113 FAX - 020 7905 2381
-----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help- bounces at stat.math.ethz.ch] On Behalf Of Mauricio Cardeal Sent: 25 January 2007 13:19 To: r-help at stat.math.ethz.ch Subject: [R] filling the area Please, how to fill the area under the curve? x <- c(1:10) y <- c(rnorm(10)) plot(x,y) lines(x,y) Thanks, Mauricio Cardeal
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code.
Thank you all. One more question about the syntax below: min(y) twice, is it? polygon(c(min(x), x, max(x)), c(min(y), y, min(y)), col = "blue") polygon( c(min(x), x, max(x)), c( min(y), y, min(y)), density=100 ) Best whises, Mauricio Marc Schwartz escreveu:
On Thu, 2007-01-25 at 10:18 -0300, Mauricio Cardeal wrote:
Please, how to fill the area under the curve?
x <- c(1:10)
y <- c(rnorm(10))
plot(x,y)
lines(x,y)
Thanks,
Mauricio Cardeal
See ?polygon x <- 1:10 y <- rnorm(10) plot(x,y, type = "o") polygon(c(min(x), x, max(x)), c(min(y), y, min(y)), col = "blue") HTH, Marc Schwartz __________ NOD32 1.1752 (20060912) Information __________ This message was checked by NOD32 antivirus system. http://www.nod32.com
Yep. Keep in mind that you need to define the complete boundaries of the region to be colored. So you need to add the coordinates of the lower left and lower right hand points, which are [min(x), min(y)] and [max(x), min(y)]. HTH, Marc
On Thu, 2007-01-25 at 11:14 -0300, Mauricio Cardeal wrote:
Thank you all. One more question about the syntax below: min(y) twice, is it? polygon(c(min(x), x, max(x)), c(min(y), y, min(y)), col = "blue") polygon( c(min(x), x, max(x)), c( min(y), y, min(y)), density=100 ) Best whises, Mauricio Marc Schwartz escreveu:
On Thu, 2007-01-25 at 10:18 -0300, Mauricio Cardeal wrote:
Please, how to fill the area under the curve?
x <- c(1:10)
y <- c(rnorm(10))
plot(x,y)
lines(x,y)
Thanks,
Mauricio Cardeal
See ?polygon x <- 1:10 y <- rnorm(10) plot(x,y, type = "o") polygon(c(min(x), x, max(x)), c(min(y), y, min(y)), col = "blue") HTH, Marc Schwartz
An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/r-help/attachments/20070125/6f40ac76/attachment.pl