I have a boolean matrix:
mm <- structure(c(TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE,
FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRU
You can do this using ggplot2's geom_tile and reshape2's melt:
library(ggplot2)
library(reshape2)
melted <- melt(mm)
ggplot(melted, aes(x = Var2, y = Var1, fill = value)) + geom_tile() +
scale_fill_manual(values = c("white", "black"))
To make it a bit neater, you could remove the legend and the gray edges with some adjustments to the theme:
ggplot(melted, aes(x = Var2, y = Var1, fill = value)) + geom_tile() +
scale_fill_manual(values = c("white", "black")) +
theme_bw() +
theme(legend.position = "none")
Final output:
