更改ggplot R中生成的热图的单元格大小?

时间:2015-11-12 23:15:00

标签: r ggplot2 heatmap

以下是我制作的热图示例:enter image description here

    id<-c(1:10)
    var1<-c(rnorm(10,3,1))
    var2<-c(rnorm(10,5,1))
    dat<-data.frame(cbind(id,var1,var2))
    data<-melt(dat,id.var="id",value.var=c("var1","var2"))
    ggplot(data, aes(variable, id)) + geom_tile(aes(fill = value), colour = "white") + scale_fill_gradient(low = "gray", high = "black")

我想更改热图中每个单元格的大小。我希望每个单元格都是一个小方块,如: enter image description here

我试过了:

ggplot(data, aes(variable, id)) + geom_tile(aes(fill = value), colour = "white",size=4) + scale_fill_gradient(low = "gray", high = "black")  

ggplot(data, aes(variable, id,height=200,width=200)) + geom_tile(aes(fill = value), colour = "white",size=4) + scale_fill_gradient(low = "gray", high = "black")  

但它们都不起作用。

0 个答案:

没有答案