本文介绍了单元格之间的ggplot图块线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用ggplot和geom_tile
形成热图.我希望在单元之间插入一些微弱的线条.
I am using ggplot and geom_tile
to form heatmaps. And I wish to insert some faint lines between the cells.
例如:
我的ggplot geom_tile
热图:
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
我想要的东西(来自R中的d3heatmap包)
What I desire (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 can't post any pictures)Thanks!
推荐答案
只需将color = "gray"
添加到您的geom_tile
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")
将为您提供此图,并在图块之间加上线条:
Will give you this figure with lines between the tiles:
您可以使用size
来放大或缩小线条,和/或使用color = white
.
You can play with size
to make the lines bigger or smaller , and/or use color = white
.
这篇关于单元格之间的ggplot图块线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!