I am using ggplot2 to draw a heatmap with a few color blocks in each line. Like this:
Basically each row will have 200 numbers represent 200 bins, each bin would either have number 1, 2, 3 and 4, which correspond to white, red, blue and orange color.
What I want to do is to align the red block to same column vertically, which means for other rows, have to apply an x-axis offset.
I am using ggplot2 and qplot for this figure, did anyone know how to do the alignment? Thanks a lot.
The code to produce this figure:
library(ggplot2)
library(reshape2)
dat <- read.table('http://wangftp.wustl.edu/~dli/fimo.near.3ins', header=FALSE)
dat$V2 <- factor(dat$V2)
dat.m <- melt(dat, id.vars=c("V1","V2"))
col2=c('white','red','blue','orange')
qplot(variable, V1, fill=col2[value], data=dat.m, geom="tile") + theme_bw() + scale_fill_identity(breaks=col2, guide="legend") + theme(axis.title.x = element_blank(), axis.text.x = element_blank(), axis.text.y = element_blank(), axis.title.y = element_blank(), legend.title = element_text(size=18), legend.text = element_text(size=16),axis.ticks.x = element_blank(),axis.ticks.y = element_blank(), panel.grid=element_blank()) + geom_hline(aes(yintercept=V1))