[R] how to draw a vertical line from points to x-axis

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Sun Sep 7 23:29:54 CEST 2008

2008/9/7 Anny Huang <annylhuang at gmail.com>:
> Hello,
> I want to know how to draw a line connecting each point to the x-axis
> perpendicularly (i.e. a vertical line).
> abline(v=...) seems not to work for my purpose, because it runs over the
> data point. Can anyone help? Thanks.

 If your x-axis is at y=zero then plot with type='h' will do this:


 but it will draw lines *up* if the value is negative:


 Or do you really want the lines to come right down to the axis line?
In which case a modified version of Peter Alspach's solution which
goes down to the limit of the plot instead of zero should work. See
help(par) for what par()$usr is all about.

 y= 6+0:10


More information about the R-help mailing list