Good day!
The client wants the color of the line of the function graph (normal distribution) to be shaded as the gradient of the specified colors.
I use this code to build a graph (ggplot):
p <-ggplot(f_table) + geom_histogram( aes( value, colour = ..x.. ), binwidth = 1, fill = I("white") )+ stat_function(fun = function(x) dnorm(x, mean = mean(f_table$value), sd = sd(f_table$value)) *length(f_table$value), size = 1, colour = "gray" )+ geom_tile( aes( x=seq(1:12), y = -0.1, fill =..x.. ), height = 0.2 ) + scale_x_continuous( breaks = seq(0, 10), expand = c(0,0), limits = c(0.5, 10.5) )+ scale_y_continuous( expand = c(0.01, 0) )+ scale_fill_gradientn( colours = clr )+ scale_colour_gradientn( colours = clr )+ theme_minimal()+ xlab("") + ylab("") + theme ( plot.margin = margin(10, 10, 10, 10) , legend.position = "none" , panel.grid = element_blank() , axis.line.y = element_line(size = 0.5, color = "grey80") , axis.ticks.y = element_line(size = 0.5, color = "grey80") , axis.ticks.length = unit (3, "mm") ) p here clr is a vector:
> clr [1] "#FF0000" "#FFC000" "#5B9BD5" "#00B050" It turned out to decorate the outlines of the histogram bars, but how in ggplot to color the distribution graph line itself with a gradient?
You should get something like this (customer sketch): 
Thanks in advance for your help!


