# Setup dummy data
df <- rbind(data.frame(x = 1:3, y = 1, v = NA, w = 1:3, z = NA),
data.frame(x = 1:3, y = 2, v = 1:3, w = NA, z = NA),
data.frame(x = 1:3, y = 3, v = NA, w = NA, z = 1:3))
ggplot(df, aes(x, y)) +
geom_raster(aes(fill1 = v)) +
geom_raster(aes(fill2 = w)) +
geom_raster(aes(fill3 = z)) +
scale_fill_multi(aesthetics = c("fill1", "fill2", "fill3"),
colours = list(c("white", "red"),
c("black", "blue"),
c("grey50", "green")))
Run the code above in your browser using DataLab