Reputation: 11
I'm trying to plot something similar to this graphic, see p.32, figure 14.
Seems quite simple, but I have not been able to find a specific example through online searching. If anyone can help, I would really appreciate it.
Upvotes: 1
Views: 113
Reputation: 8691
How about this:
library(ggplot2)
df<-expand.grid(x=LETTERS,y=1:20)
df$var<-runif(nrow(df))
ggplot(df[sample(1:nrow(df),200),]) + theme_bw() + # subset of df to include blanks
geom_tile(aes(x=x,y=y,fill=var)) + #geom_tile
scale_fill_gradient2(low="green",mid="yellow",high="red",midpoint=0.5) + # add fill gradient
scale_y_discrete(breaks=1:20,labels=1:20) +
coord_fixed(ylim=c(0.5,20.5))
you can tinker with the scale_fill...
functions to acheive whatever layout you want, either based on var (continuous or discrete), or some set of rules.
Upvotes: 2