Plotly histogram get number of bins or bin size

I’m using plotly.js to draw a histogram of a bunch of points that roughly follows a normal distribution. I want to draw a normal distribution curve on top of it. However, I can only do that if I know what the bin size is.

y = probabilityDensityFunction(x, mean, sigma) * number_of_points * BIN_SIZE

I’d like to keep using the autobinning rather than specifying the bin size manually.

Is there any way to get the bin size from a plotly plot?

You can try digging into our internal variables:

gd._fullData[0].xbins

should have the values you want.

1 Like

How would we access those internal variables in r?