R plotly histogram uncorrect observations count

I'm having some trouble with an histogram plot with 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 plotenter image description here

Upvotes: 0

Views: 461

Answers (1)

tomasu
tomasu

Reputation: 1438

You could try building your histogram in ggplot2 and use the ggplotly function like this:

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

Upvotes: 1

Related Questions