[R] rotate column names in large matrix

Chris Stubben stubben at lanl.gov
Mon Nov 15 23:25:04 CET 2010

You could display the matrix as an image then add column names (rotated used
srt) if you really want them. 

x <- cor(matrix(rnorm(600), 60, 100))  

# set margins with extra space at top and xpd=TRUE to write outside plot
op<-par(mar=c(1,1,5,1), xpd=TRUE)

# display image without the 90 degree counter clockwise rotation
image(t(x[nrow(x):1,]), axes=FALSE)

## add 100 column names
y<-paste("column", 1:100)
text( seq(0,1,length=100) , 1.01, y,  pos = 2, srt = 270, offset=0, cex=.7)

Chris Stubben

Lara Poplarski wrote:
> I have a large (1600*1600) matrix generated with symnum, that I am using
> to
> eyeball the structure of a dataset.
> I have abbreviated the column names with the abbr.colnames option. One way
> to get an even more compact view of the matrix would be to display the
> column names rotated by 90 degrees.
> Any pointers on how to do this would be most useful. Any other tips for
> displaying the matrix in compact form are of course also welcome.

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

More information about the R-help mailing list