简体   繁体   English

R绘图直方图不正确的观察计数

[英]R plotly histogram uncorrect observations count

I'm having some trouble with an histogram plot with plotly. 我在使用plotly直方图时遇到了一些麻烦。 It seems that the bins are wrong populated. 似乎垃圾箱的填充错误。 Why? 为什么?

aaa<-seq(-0.1,0.45,0.005)
plot_ly(y=~aaa,
        type="histogram",
        showlegend=FALSE,
        autobiny=FALSE,
        ybins=list(
              start=-0.1,
              end=0.45,
              size=0.005
              ),
        marker=list(
              line=list(
                  width=1
                  )
               )
)

The code create this wrong plot 代码创建了这个错误的情节 在此处输入图片说明

You could try building your histogram in ggplot2 and use the ggplotly function like this: 您可以尝试在ggplot2构建直方图,并使用ggplotly函数,如下所示:

library(ggplot2)
library(plotly)
ggplotly(ggplot(data.frame(aaa), aes(aaa)) + geom_histogram(binwidth = 0.005))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM