[R] combining plots (curve + Plot functions)

Johannes Huesing johannes at huesing.name
Mon Nov 1 07:28:44 CET 2010


mmstat at comcast.net <mmstat at comcast.net> [Mon, Nov 01, 2010 at 04:11:53AM CET]:
> Hello, 
>   
> What I really want to do is to add a rejection region in the 
> form of a long rectangle to a density plot I have drawn. 
> I am getting  2 plots.  
> 
> How can I add rectangle to first plot?  see code below. 
> First section works fine.  It just is not quite what I want. 
> 
> # NORMAL DISTRIBUTION PLOT OF RAW DATA WITH UPPER CRITICAL LEVEL - ok 
> xcrit=144.1 
> # *** single-sample Upper one-tailed hypothesis Test, z statistic *** 
> cord.x <- c(xcrit,seq(xcrit,200,0.01),200) 
> cord.y <- c(0,dnorm(seq(xcrit,200,0.01),140,15),0) 
> curve(dnorm(x,140,15),xlim=c(80,200),main='Normal PDF',ylab="Probability") 
> polygon(cord.x,cord.y,col='orange') 
> 

Another call to polygon()?

polygon(rep(c(144.1, 200), each=2), rep(c(0, .03, .03, 0)))


-- 
Johannes Hüsing               There is something fascinating about science. 
                              One gets such wholesale returns of conjecture 
mailto:johannes at huesing.name  from such a trifling investment of fact.                
http://derwisch.wikidot.com         (Mark Twain, "Life on the Mississippi")



More information about the R-help mailing list