[R] add diagonal line

Gavin Simpson gavin.simpson at ucl.ac.uk
Thu Oct 28 08:38:16 CEST 2010


On Wed, 2010-10-27 at 13:17 -0200, Marcelo Lima wrote:
> Hi,
> 
> I would like to add a line on the diagonal of a covariance matrix, is there
> a quick way to do it besides abline?
> 
> Thanks!

What's wrong with abline()? It does exactly what you want.

By the way,  reproducible example such as requested by David would
something like:

cmat <- matrix(rnorm(100), ncol = 10)
diag(cmat) <- 1
contour(1:10, 1:10, cmat)
abline(11, -1, col = "red", lwd = 2)
box()

I.e. some code with example data that shows us what you are trying to
do. It is not always possible to grep the meaning from a textual
description sufficiently well to be able to move from there to code.
This is discussed in the posting guide.

HTH

G

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



More information about the R-help mailing list