I am using plotly to plot a histogram for a dataset I am working with
test <- data.frame(y = rgamma(1000, shape = 0.25, rate = 0.0054))
plot_ly(x = ~test$y, type = "histogram", nbinsx = "23")
The plot as such is fine but I am unclear how to draw a smooth density curve flowing through the contours of the histogram.
Plotly reference manual suggests,
A histogram trace is initialized with plot_ly or add_trace:
plot_ly(df, type="histogram"[, ...])
add_trace(p, type="histogram"[, ...])
and there is a histnorm (enumerated: "" | "percent" | "probability" | "density" | "probability density" ) histonorm function which i assume will allow users to draw a density curve but I am not sure how to use this function.
Interested to find out how others have approached this problem. Any tips or suggestions are much appreciated.

scaledensity so that it is more clear on the plot.test = data.frame(y = rgamma(1000, shape = 0.25, rate = 0.0054)) ; fit = density(test$y) ; scale = 500/max(fit$y) ; plot_ly() %>% add_histogram(x = ~test$y, name = "Histogram") %>% add_lines(x = fit$x, y = scale*fit$y, name = "Density")- d.b