Hi Frank,
It's not inaccuracy, exactly, and it's intentional.
The default behavior is to use a round endcap on a line, and with such
a large linewidth that endcap is arcing below and above the starting
points.
This being R, there's a par for that: putting lend=1 in your lines()
statements will give you the result you're looking for.
Sarah
On Thu, Jun 16, 2011 at 3:03 PM, Frank Harrell <f.harrell at
vanderbilt.edu> wrote:> 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)
> }
>
>
--
Sarah Goslee
http://www.functionaldiversity.org