plotly/plotly.R

area under normalized histogram is not 1 in plotly R

ArunRegmi opened this issue · 1 comments

in https://plotly.com/r/histograms/, under 'Normalized Histogram' heading, histogram is generated as
library(plotly)
fig <- plot_ly(x = ~rnorm(50),
type = "histogram",
histnorm = "probability")

fig

The area of normalized histogram is as shown in the website is expected to be 1, but obtained close to 0.5.

You can achieve your desired result using histnorm = "probability density" (see e.g. here):

library(plotly)

set.seed(123)

fig <- plot_ly(
  x = ~ rnorm(50),
  type = "histogram",
  histnorm = "probability density"
)

fig