1

我需要用 plotly 创建绘图,但我想自己确定 x 轴中断间隔。

我需要这样的东西。

在此处输入图像描述

我搜索了很多,找不到答案。

感谢您的帮助。

4

1 回答 1

0

这里的问题不是 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
于 2019-10-09T13:26:45.053 回答