✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚾️ It's finally Baseball season! Root for the home team... & Register for our Sports Analytics Webinar!

Histogram bar width

Hi, I am plotting some distributions with plotly and I have an issue with the bars width.
I am able to correctly plot a distribution when the values are between 0 and 1 with 2 decimal accuracy, hardcoding the width values as 0.01, since the number of bins is 100.

But I am having some issues related to the bar width when this values are in another range:

for example, for [0,4]

and for [0,38]
image

with width fixed to 0.01

How can I solve that? It seems there is not a linear transformation since fixing to 0.01 for [0,4] leads to overlapping bars while values for [0,30] lead to a insufficient bar width.
Another thing is that I am converting the matplotlib original graph to plotly by using_

tls.mpl_to_plotly(fig)

Thanks.

Have you tried not setting width all together, and let plotly autosize the bars?