Ggplot graphic line between cells

I use ggplot and geom_tile to generate heatmaps. And I want to insert some weak lines between the cells.

For instance:

My ggplot geom_tile heatmap:

 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 

What I want (from d3heatmap package in R)

 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 

(Sorry, you can’t leave photos) Thank you!

+5
source share
1 answer

Just add color = "gray" to your 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") 

Gives you this figure with the lines between the plates: enter image description here

You can play with size to make the lines bigger or smaller, and / or use color = white .

+6
source

All Articles