Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. library(plotly)
  2.  
  3. y <- rgamma(1000, shape = 0.25, rate = 0.0054)
  4. dens <- data.frame(x = density(y)$x, y = density(y)$y)
  5. miny <- 0
  6. maxy <- max(dens$y)
  7.  
  8. plot_ly() %>%
  9. add_histogram(x = y) %>%
  10. 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))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement