An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/r-help/attachments/20070913/c4872466/attachment.pl
how to plot shaded area under a curve?
6 messages · gallon li, jim holtman, Wayne.W.Jones at shell.com +2 more
?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? ______________________________________________ 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?
?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? ______________________________________________ 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? ______________________________________________ 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.
in addition to Charles' suggestion which is more advanced, I found the link below very helpful. http://www.feferraz.net/en/shaded.html good luck AA. ----- Original Message ----- From: "Charles Annis, P.E." <Charles.Annis at StatisticalEngineering.com> To: "'gallon li'" <gallon.li at gmail.com>; "'r-help'" <r-help at stat.math.ethz.ch> Sent: Thursday, September 13, 2007 9:27 AM Subject: Re: [R] how to plot shaded area under a curve?
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. ______________________________________________ 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.