[R] rotate column names in large matrix

Chris Stubben stubben at lanl.gov
Tue Nov 16 18:59:02 CET 2010


Just increase the margins on the left side and add the rownames

x <- cor(matrix(rnorm(600), 60, 100))
rownames(x)<-paste("row", 1:100)
op<-par(mar=c(1,5,1,1), xpd=TRUE)
image(t(x[nrow(x):1,]), axes=FALSE)
 text(-0.01, seq(0,1,length=nrow(x) ), rownames(x), pos = 2,  offset = 0,
cex = .7)

Another option is to search the R graphics manual at
http://rgm2.lab.nig.ac.jp/RGM2/images.php and maybe you'll find a function
in all those packages that plots what you need.   Try searching for "symnum"
or "image key" or "matrix plot" (in quotes).  For "matrix plot", there's a
function in the plotrix package that will add a key or even show values in
the "cells"..

library(plotrix)
color2D.matplot(x, show.legend=TRUE, red=1, blue=0)

Chris




Lara Poplarski wrote:
> 
> Chris, could you please suggest how to modify what you sent to also show
> the
> same labels as (horizontal) row names? I have not yet mastered the details
> of R graphics...
> 

-- 
View this message in context: http://r.789695.n4.nabble.com/rotate-column-names-in-large-matrix-tp3043493p3045366.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list