0

I have a matrix with 641*976 data points. When I apply the Heatmap function in R than the result is a quadratic Heatmap. I would like that the Heatmap has the same proportions as my input matrix (squared cells).

heatmap(as.matrix(Data), scale = "none", col = my_palette, 
breaks = col_breaks, main =  "Heatmap of emission ratios", Rowv = NA, Colv = NA)

I can demonstrate you my situation with the mtcars data set. The dimensions of this data set is 32*11. When you generate the Heatmap of the mtcars data set then you get a quadratic Heatmap. Even though the input matrix is rectangular.

dim(mtcars)
heatmap(as.matrix(mtcars), scale = "none", Rowv = NA, Colv = NA)

I would like that the Heatmap is also rectangular. Meaning that each cell of the Heatmap is quadratic instead of rectangular. In the Heatmap of the mtcars dataset it is good visible that this is not the case.

Another problem I have is with the orientation of the Heatmap. When we check the dataset then we see that the cell of the row "Mazda RX4" and the column mpg is in the upper left corner.

View(mtcars)

But in the Heatmap the cell in the upper left corner contains the information of the row "Volvo 142E" and the column "mpg". How can I adapt the Heatmap in such a way that the orientation is exactly the same as in the input matrix. Meaning in the upper left corner the cells contains the information of the row "Mazda RX4" and the column mpg.

Werner Hertzog
  • 2,002
  • 3
  • 24
  • 36
stefx
  • 25
  • 10
  • What do you mean by **squared Heatmap**? Can you provide a reproducible example (see here: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)? – Majid Apr 19 '19 at 14:08

1 Answers1

0

Meanwhile I found a solution for my problem. I switched to the heatmap.2 function. This allows me to design the length and width of the Heatmat with the margins command.

stefx
  • 25
  • 10