我想创建一个geom_tile,不仅可以填充颜色,还可以填充纺织品,这可能吗?
基本上,我有这张图:
但是在黑白模式下很难看出A组和B组之间的区别。因此,我认为如果它可以合作一些纺织品会更好。例如,对于值0.0到1.0,颜色从白色到黑色没有图案,对于-1.0到0.0,颜色是黑色到白色但是有它上面有某种图案/纺织品。
这有可能吗?
我从这个问题中受到启发:Filling bars in barplot with textiles in ggplot2 并想知道这是否可以应用于geom_tile()?
用于生成这些图表的代码:
library(reshape2)
library(ggplot2)
dat = rbind.data.frame(c(0.1038, 0.1224, 0.0906, 0.1859, -0.0811, "Group.A"),
c(-0.1551, -0.1829, -0.1354, -0.2776, 0.1212, "Group.B"))
colnames(dat) = c("A", "B", "C", "D", "E", "Group")
m = melt(sub.all, id.vars = "Group")
#Red/green
ggplot(m, aes(variable, factor(Group))) + geom_tile(aes(fill = value), colour = "white") +
scale_fill_gradient2(low = "green", high = "red", mid = "white", limits = c(-1,1)) + coord_flip()
#Black/white
ggplot(m, aes(variable, factor(Group))) + geom_tile(aes(fill = value), colour = "white") +
scale_fill_gradient2(low = "grey50", high = "black", mid = "white", limits = c(-1,1)) + coord_flip()