[R] combining plots (curve + Plot functions)

mmstat at comcast.net mmstat at comcast.net
Mon Nov 1 04:11:53 CET 2010


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') 

# NORMAL DISTRIBUTION PLOT OF RAW DATA WITH UPPER CRITICAL LEVEL - 2 plots? 
xcrit=144.1 
# *** single-sample Upper one-tailed hypothesis Test, z statistic *** 
curve(dnorm(x,140,15),xlim=c(80,200),main='Normal PDF',ylab="Probability") 
plot(c(144.1, 200), c(0, .03), type= "n") 

Thanks. 
Mary A. Marion 



More information about the R-help mailing list