[R] lines(..., lwd=3) inaccuracy

Frank Harrell f.harrell at vanderbilt.edu
Thu Jun 16 21:03:02 CEST 2011


Using a line width > 1 results in not only a thicker line but also some fuzz
in the other direction, as shown in this example program.  You will see that
the thick vertical black lines extend below the gray scale horizontal lines. 
Does anyone know whether this is intended or is it a bug?  The application
is for displaying a correlation matrix (here just some random U(0,1)s). 
Thanks -Frank


par(mar=c(1,2,0,0), xpd=NA)
set.seed(1)
r <- matrix(runif(16), nrow=4, dimnames=list(NULL, paste('x', 1:4, sep='')))
p <- nrow(r)
v <- colnames(r)
plot(c(-.35,p+.5),c(.5,p+.25), type='n', axes=FALSE,
     xlab='',ylab='')
text(rep(.5,p), 1:p, v, adj=1)
maxabsr <- max(abs(r[row(r) != col(r)]))
for(i in 1:p) {
  for(j in 1:p) {
    if(i >= j) next
    lines(c(i,i),c(j,j+r[i,j]/maxabsr/2), lwd=3)
    lines(c(i-.2,i+.2),c(j,j), col=gray(.7))
  }
  text(i, i, v[i], srt=-45, adj=0)
}


-----
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: http://r.789695.n4.nabble.com/lines-lwd-3-inaccuracy-tp3603375p3603375.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list