Is there an easier way to make this graph *without* having to specify all of the separate segment arguments at the end?> x <- c(1,2) > off <- c(4,5.5) > def <- c(5.5,5.9) > par(fg="lightblue4") >plot(x,off,type="o",col="dodgerblue4",ylim=c(2,7),xlim=c(0.7,2.3),axes=F,xlab="Labor Condition",ylab="Willingness to Join",lwd=3)> lines(def,type="o",pch=22,lty=2,col="firebrick",lwd=3) > axis(1,at=x,lab=c("Sufficient","Insufficient")) > axis(2,at=2:7,lab=c("2","3","4","5","6","7")) > segments(0,2,2.3,2) > segments(0,3,2.3,3) > segments(0,4,2.3,4) > segments(0,5,2.3,5) > segments(0,6,2.3,6) > segments(0,7,2.3,7)anthony [[alternative HTML version deleted]]
Tena koe Anthony You could try: segments(rep(0,6), 2:7, rep(2.3, 6), 2:7) HTH ... Peter Alspach> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Anthony Lopez > Sent: Friday, 21 May 2010 5:39 a.m. > To: R-help at r-project.org > Subject: [R] lines on plot > > Is there an easier way to make this graph *without* having to specify > all of > the separate segment arguments at the end? > > > x <- c(1,2) > > off <- c(4,5.5) > > def <- c(5.5,5.9) > > par(fg="lightblue4") > > >plot(x,off,type="o",col="dodgerblue4",ylim=c(2,7),xlim=c(0.7,2.3),axes> F,xlab="Labor> Condition",ylab="Willingness to Join",lwd=3) > > lines(def,type="o",pch=22,lty=2,col="firebrick",lwd=3) > > axis(1,at=x,lab=c("Sufficient","Insufficient")) > > axis(2,at=2:7,lab=c("2","3","4","5","6","7")) > > segments(0,2,2.3,2) > > segments(0,3,2.3,3) > > segments(0,4,2.3,4) > > segments(0,5,2.3,5) > > segments(0,6,2.3,6) > > segments(0,7,2.3,7) > > anthony > > [[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.
Some variation around
axis(2,at=2:7,lab=c("2","3","4","5","6","7"),
tck=1)
should do it? See tck in help("par").
Hope this helps.
Allan.
On 20/05/10 18:38, Anthony Lopez wrote:> Is there an easier way to make this graph *without* having to specify all
of
> the separate segment arguments at the end?
>
>
>> x<- c(1,2)
>> off<- c(4,5.5)
>> def<- c(5.5,5.9)
>> par(fg="lightblue4")
>>
>>
>
plot(x,off,type="o",col="dodgerblue4",ylim=c(2,7),xlim=c(0.7,2.3),axes=F,xlab="Labor
> Condition",ylab="Willingness to Join",lwd=3)
>
>>
lines(def,type="o",pch=22,lty=2,col="firebrick",lwd=3)
>> axis(1,at=x,lab=c("Sufficient","Insufficient"))
>>
axis(2,at=2:7,lab=c("2","3","4","5","6","7"))
>> segments(0,2,2.3,2)
>> segments(0,3,2.3,3)
>> segments(0,4,2.3,4)
>> segments(0,5,2.3,5)
>> segments(0,6,2.3,6)
>> segments(0,7,2.3,7)
>>
> anthony
>
> [[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.
>
On 2010-05-20, at 2:38 PM, Anthony Lopez wrote:> Is there an easier way to make this graph *without* having to specify all of > the separate segment arguments at the end? > ... > axis(2,at=2:7,lab=c("2","3","4","5","6","7")) > segments(0,2,2.3,2) > segments(0,3,2.3,3) > segments(0,4,2.3,4) > segments(0,5,2.3,5) > segments(0,6,2.3,6) > segments(0,7,2.3,7)abline(h = 2:7) grid() is another option also, axis(2, at = 2:7) is all you need Sean