go.Histogram count maximum number of observations across all bins

Hi,

Let’s say I do:

import random
trace=go.Histogram(y=[random.normalvariate(0.5, 2) for i in range(0,100)])

Is there a way to count the maximum number of observations across all histogram bins? I.e., let’s say the maximum is in bin [0.5-0.6], and the number of obsrvations is 32. How would I get that number, 32? Is there any function that would compute that based on go.Histogram binning function?

Hi @dnaiel this is not possible, the computation of bin and counts is done in Javascript and not returned to Python. However, go.Histogram has a lot of options, so that maybe there is a workaround for what you want to do with this numbers (you did not say, if you say more we might be able to help you), using one of these options. If you really need this number I would suggest using numpy with np.histogram with a fixed number of bins (which returns all the bin positions and counts), and then plot the go.Histogram with the same number of bins (nbinsx parameter).

1 Like