Skip to content
Prev 139577 / 398506 Next

How to create following chart for visualizing multivariate time series

Megh Dal <megh700004 at yahoo.com> wrote in
news:450810.95514.qm at web58113.mail.re3.yahoo.com:
His second posting did:
<https://stat.ethz.ch/pipermail/r-help/2008-March/155785.html>
This seems to do what is requested. You would not want to attempt to 
"blank out" the above-diagonal entries inside the levelplot function, 
but rather directly work on the matrix data points. You will probably 
need to work on prettying up the axis labels within levelplot, since 
they are not properly labeled:

dat = matrix(rnorm(200*200), 200, 200)
#now set all values above the diagonal to minimum

dat[row(dat) > col(dat)] <- min(dat)

# use reversed row.values to reverse the row plotting order.

colkey <- colorRampPalette(c('red','blue'))(32)
levelplot(tdat, colorkey=list(col=colkey),
   col.regions=(col=colkey), row.values=200:1)

Above diagonal matrix elements are now all very "red".