Re: [R] Vertical Line on Plot

From: Gavin Simpson <gavin.simpson_at_ucl.ac.uk>
Date: Fri 26 May 2006 - 02:52:00 EST

On Thu, 2006-05-25 at 09:26 -0700, Peter Lauren wrote:
> I was wondering what would be the best way to put a
> vertical line on a graph made with plot(). I can get
> an horizontal line by plotting a vector where every
> element has the same value but it is not as clear how
> a vertical line should be done.
>
> Thanks very much,
> Peter.

Is this what you want?

set.seed(12345) # reproducible random numbers datx <- rnorm(100) # some example data
daty <- rnorm(100)
plot(datx, daty) # plot it

abline(v = mean(datx)) # add vertical line at mean of x
abline(v = 0.5, col = "red") # same but at x == 0.5
abline(h = mean(daty)) # horizontal lines
abline(a = 0, b = 1) # lines of arbitrary intercept and slope

see ?abline

HTH G

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
*  Note new Address, Telephone & Fax numbers from 6th April 2006  *
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson
ECRC & ENSIS                  [t] +44 (0)20 7679 0522
UCL Department of Geography   [f] +44 (0)20 7679 0565
Pearson Building              [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street                  [w] http://www.ucl.ac.uk/~ucfagls/cv/
London, UK.                   [w] http://www.ucl.ac.uk/~ucfagls/
WC1E 6BT.
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Fri May 26 03:04:12 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 26 May 2006 - 04:10:22 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.