我需要用 plotly 创建绘图,但我想自己确定 x 轴中断间隔。
我需要这样的东西。
我搜索了很多,找不到答案。
感谢您的帮助。
这里的问题不是 x 轴本身,而是垃圾箱的数量。您可以使用以下方式进行调整nbinsx
:
plot_ly(x, type = "histogram", nbinsx = 20)
代码 1:
library(plotly)
set.seed(1)
numbers <- rnorm(100,20, 20)
p1 <- plot_ly(x = ~numbers,type = "histogram")
p1
情节1:
代码 2:
p2 <- plot_ly(x = ~numbers,type = "histogram", nbinsx=20)
p2
情节2:
代码 2:
p3 <- plot_ly(x = ~numbers,type = "histogram", nbinsx=20)
p3
情节3:
代码 3:
p3 <- plot_ly(x = ~numbers,type = "histogram", nbinsx=5)
p3