1

I want to put custom axes in pheatmap from pheatmap package. I tried xlab="Custom x label" and ylab="Custom y label" but it did not work. I also could not figured out how to change the position of legend.

Minimum working example:

library(pheatmap)
# Create test matrix
test = matrix(rnorm(200), 20, 10)
test[1:10, seq(1, 10, 2)] = test[1:10, seq(1, 10, 2)] + 3
test[11:20, seq(2, 10, 2)] = test[11:20, seq(2, 10, 2)] + 2
test[15:20, seq(2, 10, 2)] = test[15:20, seq(2, 10, 2)] + 4
colnames(test) = paste("Test", 1:10, sep = "")
rownames(test) = paste("Gene", 1:20, sep = "")

# Draw heatmaps
pheatmap(test)

pheatmap(test, xlab = "Custom x label", ylab = "Custom y label")

enter image description here

halfer
  • 19,824
  • 17
  • 99
  • 186
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
  • Why not use an alternative heatmap function, e.g. `library(gplots); mypal <- colorRampPalette(rev(brewer.pal(n = 7, name ="RdYlBu"))); heatmap.2(test, col = "mypal", trace="none", symbreaks=F, symkey=F, xlab = "Custom x label", ylab = "Custom y label")`... – lukeA Dec 20 '15 at 11:54
  • Thanks @lukeA for your nice suggestion. However, I need to use some functionalities which are only available in `pheatmap`. – MYaseen208 Dec 20 '15 at 12:44
  • Waiting might @akrun has some solution. – MYaseen208 Dec 20 '15 at 14:20
  • These are two independent questions. The first half about the custom x and y labels has been answered here on [stack overflow](https://stackoverflow.com/questions/17538830/x-axis-and-y-axis-labels-in-pheatmap-in-r). – Viktor Horváth Sep 12 '21 at 19:01

0 Answers0