单元格之间的ggplot tile线

Kev*_*in 5 r heatmap ggplot2

我正在使用ggplot并geom_tile形成热图.我希望在细胞之间插入一些微弱的线条.

例如:

我的ggplot geom_tile热图:

library(ggplot2)
library(reshape2)
data("iris")
x = melt(cor(iris[,1:4]))
ggplot(data=x,aes(Var1,Var2,fill=value)) + geom_tile() # No line between the cells
Run Code Online (Sandbox Code Playgroud)

我想要什么(来自R中的d3heatmap包)

library(d3heatmap)
data("iris")
x = cor(iris[,1:4])
d3heatmap(cor(iris[,1:4]),Rowv = F,Colv = F) #There is a faint line between the cells
Run Code Online (Sandbox Code Playgroud)

(抱歉无法发布任何图片)谢谢!

RHA*_*RHA 7

只需添加color = "gray"到您的geom_tile

library(ggplot2)
library(reshape2)
data("iris")
x = melt(cor(iris[,1:4]))
ggplot(data=x,aes(Var1,Var2,fill=value)) + 
  geom_tile(color = "gray")
Run Code Online (Sandbox Code Playgroud)

会给你这个数字与瓷砖之间的线条:在此输入图像描述

您可以使用size以使线条更大或更小,和/或使用color = white.