I\'m trying to plot a geom_histogram where the bars are colored by a gradient.
This is what I\'m trying to do:
library(ggplot2) set.seed(1) df <-
Not sure you can fill by val because each bar of the histogram represents a collection of points.
val
You can, however, fill by categorical bins using cut. For example:
cut
ggplot(df, aes(val, fill = cut(val, 100))) + geom_histogram(show.legend = FALSE)