Reputation: 28
Let's suppose I have a simple plot:
plot(0.3, 0.3, lwd=7)
I want to draw two lines connecting the (0.3, 0.3) point with the X and Y axis. abline
is not useful here, as it goes over the point.
I would like to apply the same solution when I have 6-7 points.
Upvotes: 0
Views: 1604
Reputation: 24074
You can use the segments
function:
Let's say the coordinates of your points are stored in vectors x
and y
, you can do:
plot(x, y, lwd=7)
segments(x0=x, y0=0, x1=x, y1=y) # segments from x axis to points
segments(x0=0, y0=y, x1=x, y1=y) # segments from y axis to points
Example with your point
x <- y <- 0.3
plot(x, y, lwd=7)
segments(x, 0, x, y)
segments(0, y, x, y)
Upvotes: 1