Skip to content

Instantly share code, notes, and snippets.

@gauden
Created May 3, 2012 22:54
Show Gist options
  • Save gauden/2590169 to your computer and use it in GitHub Desktop.
Save gauden/2590169 to your computer and use it in GitHub Desktop.
Code snippet to make tile plot in ggplot2
# snippet to make a tile plot
library("ggplot2")
x <- rnorm(5000, 0, 1.5)
y <- rnorm(5000, 0, 1.5)
df <- data.frame(cbind(x,y))
p <- ggplot(df,
aes(x=x,y=y))
p <- p + stat_bin(aes(fill=..count..,
y=cut(y,20),
x=cut(x,20)),
geom="tile",
binwidth=0.5,
position="identity")
p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment