View Full Version : Simple R plot question
How can I add an vertical line connecting two points (a,0) and (a,b).
I can do it with an arrow, but it;s not the same...
Mike White
06-11-2008, 10:38 AM
You need to plot the points first with plot and then use the lines fucntion, e.g.
a<-3
b<-4
plot(x=c(a,a), y=c(0,b))
lines(x=c(a,a), y=c(0,b), lty="solid", col="red")
# or neater
p1<-c(a,0)
p2<-c(a,b)
dat<-rbind(p1,p2)
plot(dat)
lines(dat, lty="solid", col="red")
Thnx Mike!
I wasn't patient enough to figure it out myself:)
TheEcologist
06-11-2008, 10:54 AM
How can I add an vertical line connecting two points (a,0) and (a,b).
I can do it with an arrow, but it;s not the same...
It's can be as simple as:
abline(v=a)
however if you dont want the lines to continue just use:
lines(data.frame(c(a,a),c(0,b)),type="b")
In both cases you need to plot your data first as Mike said.
How can I add an vertical line connecting two points (a,0) and (a,b).
I can do it with an arrow, but it;s not the same...
Function segements connects any two point with straight line.
>segments(x0,y0,x1,y1)
you can specify any usual parameters color, width, style.
TheEcologist
06-11-2008, 12:34 PM
Function segements connects any two point with straight line.
>segments(x0,y0,x1,y1)
you can specify any usual parameters color, width, style.
Welcome Tart and thanks didn't know that one
Thanks everyone for the feedback! All this works
The segments thing...Ah, that;s how I did it last time. It's the buddy function of arrows!!!
Powered by vBulletin™ Version 4.1.3 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.