I\'m interested in building a heatmap with geom_tile
in ggplot2 that uses a different gradient high color based on a factor.
The plot b
In general, ggplot2 does not permit multiple scales of a single type (i.e. multiple colour or fill scales), so I suspect that this isn't (easily) possible.
The best nearest approximation I can come up with is this:
df <- data.frame(expand.grid(1:5,1:5))
df$z <- runif(nrow(df))
df$grp <- rep(letters[1:2],length.out = nrow(df))
ggplot(df,aes(x = Var1,y = Var2,fill = factor(grp),alpha = z)) +
geom_tile() +
scale_fill_manual(values = c('red','blue'))
But it's going to be tough to get a sensible legend.