Dear All, May I seek your suggestion on a simple issue. I want to draw vertical lines at some positions in the following R plot. To be more specific, I wish to draw vertical lines at d=c(5.0,5.5,6) and they should go till p=c(0.12,0.60,0.20) . I haven't found any way out, though made several attempts. Please run the following commands first if you are interested in! ####################################################### psi1<-function(alpha1,beta1,alpha2,beta2,d){ exp(alpha1+beta1*d)/((1+exp(alpha1+beta1*d))*(1+exp(alpha2+beta2*d))) } alpha1<--3.5 beta1<-1 alpha2<--6 beta2<-0.72 d<-seq(0.5,10,0.01) plot(d,psi1(alpha1,beta1,alpha2,beta2,d),type="l",pch=18, ylim=c(0,1), xlab="Dose", ylab="Probabilitty") ########################################################## Many thanks for the help! Regards, Jamil. [[alternative HTML version deleted]]
Hi ?segments segments(x0=c(5.0,5.5,6), y0=c(0,0,0), y1=c(0.12,0.60,0.20)) Regards Petr> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Naser Jamil > Sent: Monday, March 11, 2013 3:10 PM > To: R help > Subject: [R] vertical lines in R plot > > Dear All, > May I seek your suggestion on a simple issue. I want to draw vertical > lines at some positions in the following R plot. To be more specific, I > wish to draw vertical lines at d=c(5.0,5.5,6) and they should go till > p=c(0.12,0.60,0.20) . I haven't found any way out, though made > several attempts. Please run the following commands first if you are > interested in! > > ####################################################### > > psi1<-function(alpha1,beta1,alpha2,beta2,d){ > exp(alpha1+beta1*d)/((1+exp(alpha1+beta1*d))*(1+exp(alpha2+beta2*d))) > } > alpha1<--3.5 > beta1<-1 > alpha2<--6 > beta2<-0.72 > > d<-seq(0.5,10,0.01) > plot(d,psi1(alpha1,beta1,alpha2,beta2,d),type="l",pch=18, ylim=c(0,1), > xlab="Dose", ylab="Probabilitty") > > ########################################################## > > > Many thanks for the help! > > Regards, > Jamil. > > [[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.
Like this: segments(x0=c(5.0,5.5,6), y0=c(0,0,0), x1=c(5.0,5.5,6), y1=c(0.12,0.60,0.20)) If you wanted them to extend the entire height of the plot, abline(v=c(5.0,5.5,6)) is simpler. Thanks for the reproducible example, Sarah On Mon, Mar 11, 2013 at 10:10 AM, Naser Jamil <jamilnaser79 at gmail.com> wrote:> Dear All, > May I seek your suggestion on a simple issue. I want to draw vertical lines > at some positions in the following R plot. To be more specific, I wish to > draw vertical lines at d=c(5.0,5.5,6) and they should go till > p=c(0.12,0.60,0.20) . I haven't found any way out, though made several > attempts. Please run the following commands first if you are interested in! > > ####################################################### > > psi1<-function(alpha1,beta1,alpha2,beta2,d){ > exp(alpha1+beta1*d)/((1+exp(alpha1+beta1*d))*(1+exp(alpha2+beta2*d))) > } > alpha1<--3.5 > beta1<-1 > alpha2<--6 > beta2<-0.72 > > d<-seq(0.5,10,0.01) > plot(d,psi1(alpha1,beta1,alpha2,beta2,d),type="l",pch=18, ylim=c(0,1), > xlab="Dose", ylab="Probabilitty") > > ########################################################## > > > Many thanks for the help! > > Regards, > Jamil. >-- Sarah Goslee http://www.functionaldiversity.org