say, I am plotting x=seq(0,5,len=100) y=-(x-5)^2 plot(x,y) how can I put some color or verticle lines below the plotted curve? [[alternative HTML version deleted]]
Wayne.W.Jones at shell.com
2007-Sep-13 10:56 UTC
[R] how to plot shaded area under a curve?
?polygon -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]On Behalf Of gallon li Sent: 13 September 2007 11:52 To: r-help Subject: [R] how to plot shaded area under a curve? say, I am plotting x=seq(0,5,len=100) y=-(x-5)^2 plot(x,y) how can I put some color or verticle lines below the plotted curve? [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org 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.
try this:> x=seq(0,5,len=100) > y=-(x-5)^2 > > plot(x,y) > polygon(c(x,x[length(x)]), c(y, y[1]), col='red')On 9/13/07, gallon li <gallon.li at gmail.com> wrote:> say, I am plotting > > x=seq(0,5,len=100) > y=-(x-5)^2 > > plot(x,y) > > how can I put some color or verticle lines below the plotted curve? > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve?
Wayne.W.Jones at shell.com
2007-Sep-13 11:13 UTC
[R] how to plot shaded area under a curve?
?polygon -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]On Behalf Of gallon li Sent: 13 September 2007 11:52 To: r-help Subject: [R] how to plot shaded area under a curve? say, I am plotting x=seq(0,5,len=100) y=-(x-5)^2 plot(x,y) how can I put some color or verticle lines below the plotted curve? [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org 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.
While it's true that polygon() is the function you need, perhaps it would be helpful to see an example of how to use polygon(). Go here: http://addictedtor.free.fr/graphiques/thumbs.php Put the mouse over the thumbnail plots to see larger pictures and look for something useful. You will find it here: http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=88 The code for this graph is downloadable too. Just click on the icon on the left of the screen. Best wishes! Charles Annis, P.E. Charles.Annis at StatisticalEngineering.com phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of gallon li Sent: Thursday, September 13, 2007 6:52 AM To: r-help Subject: [R] how to plot shaded area under a curve? say, I am plotting x=seq(0,5,len=100) y=-(x-5)^2 plot(x,y) how can I put some color or verticle lines below the plotted curve? [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org 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.