Why do I get the histogram with data not from min to max?

hi

I have a histogram in my app, and results some times are shown like this:

why is it not showing correctly (the x axis)

        dff=pd.DataFrame(dff)

        dff2_=dff.copy()
        #dff2_.dropna()
        dff2_[drop1].dropna()
        dff2_[drop1] = dff2_[drop1].sort_values()


        figure = px.histogram(data_frame=dff2_,
                x=drop1,
                marginal='violin',
                histnorm='probability density',
                title="Histogram %s "%drop1,
                template = 'plotly_dark',
                )
        figure.update_layout(transition_duration=500)
        return figure

How can I fix this?

Hello @topotaman,

This is due to the xaxis being treated as categorical instead of linear.

There are several posts on the forums about this issue. Please poke around and see if any of them help you.

1 Like

Thanks! it worked

1 Like