burger
burger

Reputation: 5883

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.

Upvotes: 3

Views: 2562

Answers (1)

Joe
Joe

Reputation: 8601

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

library(gplots)
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.

Upvotes: 4

Related Questions