I'm trying to generate a heatmap
plot using ggplot
's geom_tile
. My data have far more rows than columns.
set.seed(1)
df <- data.frame(val=rnorm(100),gene=rep(letters[1:20],5),cell=c(sapply(LETTERS[1:5],function(l) rep(l,20))))
Running:
library(ggplot2)
ggplot(df,aes(y=gene,x=cell,fill=val))+geom_tile(color="white")
produces:
How do I get the heatmap
cells to be of symmetric dimensions - squares instead of rectangles (height=width)? without distorting the dimensions of the figure.
An option is to add coord_equal
.
The default, ratio = 1, ensures that one unit on the x-axis is the same length as one unit on the y-axis
ggplot(df, aes(y = gene, x = cell, fill = val)) +
geom_tile(color = "white") +
coord_equal()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With