burger burger - 13 days ago 6
R Question

R heatmap.2 skip column or row labels

I am trying to plot a matrix of values over a range using heatmap.2. The columns are the range (for example, 0 to 100). There are too many column labels to display clearly. Is there a way to display every Nth one (0, 10, 20, etc)? I want all the values to be displayed, but I just don't want them all to be labeled.

Joe Joe

Inserting the labels into a vector of NAs and passing it to the labCol argument worked for me.

m <- matrix(rnorm(1000), ncol=100)

labvec <- c(rep(NA, 100))
labvec[c(1,20,40,60,80,100)] <- c(1,20,40,60,80,100)
heatmap.2(m, trace="none", Rowv = T, Colv = F, labCol = labvec, srtCol = 0)

Heatmap reduced column labels The srt argument can also be used to turn the labels horizontal.