How to visualize Normal Distribution Plot using Plotly?

Viewed 856

Plot- Normal Distribution chart (Six Sigma) Package- Plotly

I have tried something like this but it is not working

library(plotly)

y <- rgamma(1000, shape = 0.25, rate = 0.0054)
dens <- data.frame(x = density(y)$x, y = density(y)$y)
miny <- 0
maxy <- max(dens$y)

plot_ly() %>% 
add_histogram(x = y) %>% 
add_lines(data = dens, x = ~x, y = ~y, yaxis = "y2", line = list(width = 3)) %>% layout(yaxis2 = list(overlaying = "y", side = "right", range = c(miny, maxy), showgrid = F, zeroline = F))
0 Answers
Related