Reputation: 152
I would like to choose the number of breaks for a plotly histogram in R like the option "breaks" in hist base R.
Data
x <- rnorm(1000)
Base R
hist(x,breaks = 50)
pltoly
library(plotly)
plot_ly(x = ~x, type = "histogram") # how to add breaks option ?
Thanks for your help.
Upvotes: 0
Views: 259
Reputation: 152
I found a custom solution with the xaxis.size option
plot_ly(x = ~x, type = "histogram", xaxis = list(size = diff(range(x))/50))
Upvotes: 1
Reputation: 413
Try this :
library(plotly)
plot_ly(x = ~x, type = "histogram", nbinsx = 30)
Upvotes: 1