I am drawing the following data using geom_tile and geom_text in ggplot2
mydf Var1 Var2 dc1 bin 1 HG 0.93333333 0 2 GH 0.06666667 1 3 IG 0.80000000 0 4 GI 0.20000000 1 5 JG 0.33333333 1 6 GJ 0.66666667 0 7 KG 0.57894737 1 8 GK 0.42105263 0 9 IH 0.80000000 0 10 HI 0.20000000 1 11 JH 0.25000000 0 12 HJ 0.75000000 1 13 KH 0.20000000 0 14 HK 0.80000000 1 15 JI 0.12500000 0 16 IJ 0.87500000 1 17 KI 0.32000000 0 18 IK 0.68000000 1 19 KJ 0.28571429 0 20 JK 0.71428571 1
I draw "Var1" vs "Var2" and then use the variable "bin" as my geom_text . Currently, I have filled each slab based on scale_fill_gradient using the variable 'dc1'.
### Plotting ggplot(mydf, aes(Var2, Var1, fill = dc1)) + geom_tile(colour="gray20", size=1.5, family="bold", stat="identity", height=1, width=1) + geom_text(data=mydf, aes(Var2, Var1, label = bin), color="black", size=rel(4.5)) + scale_fill_gradient(low = "white", high = "firebrick3", space = "Lab", na.value = "gray20", guide = "colourbar") + scale_x_discrete(expand = c(0, 0)) + scale_y_discrete(expand = c(0, 0)) + xlab("") + ylab("") + theme(axis.text.x = element_text(vjust = 1), axis.text.y = element_text(hjust = 0.5), panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.border = element_rect(fill=NA,color="gray20", size=0.5, linetype="solid"), axis.line = element_blank(), axis.ticks = element_blank(), axis.text = element_text(color="white", size=rel(1.5)), panel.background = element_rect(fill="gray20"), plot.background = element_rect(fill="gray20"), legend.position = "none" )
What gives this:

What I'm trying to do (unsuccessfully) is to make the fill conditional for the variable "bin". If bin==1 , then I would like to fill in according to 'dc1'. If bin==0 , then I would like to fill in "white".
This will give the following, which I created manually as an example of the desired graph:

I tried messing around with scale_fill_gradient to try and introduce a second fill option, but it seems like I can't figure it out. Thanks for any help / pointers.
This is the dput for mydf:
structure(list(Var1 = structure(c(4L, 5L, 3L, 5L, 2L, 5L, 1L, 5L, 3L, 4L, 2L, 4L, 1L, 4L, 2L, 3L, 1L, 3L, 1L, 2L), .Label = c("K", "J", "I", "H", "G"), class = "factor"), Var2 = structure(c(1L, 2L, 1L, 3L, 1L, 4L, 1L, 5L, 2L, 3L, 2L, 4L, 2L, 5L, 3L, 4L, 3L, 5L, 4L, 5L), .Label = c("G", "H", "I", "J", "K"), class = "factor"), dc1 = c(0.933333333333333, 0.0666666666666667, 0.8, 0.2, 0.333333333333333, 0.666666666666667, 0.578947368421053, 0.421052631578947, 0.8, 0.2, 0.25, 0.75, 0.2, 0.8, 0.125, 0.875, 0.32, 0.68, 0.285714285714286, 0.714285714285714), bin = c(0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1)), .Names = c("Var1", "Var2", "dc1", "bin"), row.names = c(NA, -20L), class = "data.frame")