[R] vertical lines in R plot

William Dunlap wdunlap at tibco.com
Mon Mar 11 17:10:32 CET 2013


Also, type="h", in plot(), points(), or lines() draws vertical line segments between (x,y)
and (x,0).  E.g.,
     points(x=c(5.0,5.5,6), y=c(0.12,0.60,0.20), type="h")
does the same as
   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))

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
> Of Sarah Goslee
> Sent: Monday, March 11, 2013 8:49 AM
> To: Naser Jamil
> Cc: R help
> Subject: Re: [R] vertical lines in R plot
> 
> 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
> 
> ______________________________________________
> 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.



More information about the R-help mailing list