I'm trying to make a histogram shaded with a fill aesthetic. I have to use a continuous variable for the fill aesthetic because I want to shade it using scale_fill_gradent2(). But ggplot2 just plots a gray histogram, with no fill yet throws no error. Here is a MWE:
library(ggplot2)
dat <- rnorm(1000)
ggplot() +
geom_histogram(aes(x=dat, fill=dat))
Creates:
How do I fill the histogram with a continuous color?
I'm using ggplot2 3.2.0.

