Reputation: 75
I need to create plot with plotly but I want to determine x axis breaks intervals myself.
I need someting like this.
I searched a lot and couldn't find an answer.
Thanks for helping.
Upvotes: 1
Views: 740
Reputation: 61094
It's not the x-axis itself that's the issue here, but rather the number of bins. You can adjust that using nbinsx
like:
plot_ly(x, type = "histogram", nbinsx = 20)
Code 1:
library(plotly)
set.seed(1)
numbers <- rnorm(100,20, 20)
p1 <- plot_ly(x = ~numbers,type = "histogram")
p1
Plot 1:
Code 2:
p2 <- plot_ly(x = ~numbers,type = "histogram", nbinsx=20)
p2
Plot 2:
Code 2:
p3 <- plot_ly(x = ~numbers,type = "histogram", nbinsx=20)
p3
Plot 3:
code 3:
p3 <- plot_ly(x = ~numbers,type = "histogram", nbinsx=5)
p3
Upvotes: 1