Px.histogram `histnorm='percent'` incorrect when also using `colors`

When I use px.histogram with a histnorm parameter set to percent or probability, but I also use color, the graph looks incorrect, with percentage above 100%.
It seems that the probability is only calculated for that given bin for values that are in the given set of values delimited by the color.

  additional_params = dict(
     color='prewarmed',
     pattern_shape='prewarmed_slot',
     category_orders=dict(
        prewarmed=[True, False],
        prewarmed_slot=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, "None", None])
    )

  fig = px.histogram(df, 
    x='queued_duration',
    histnorm='percent',
    **additional_params)

This seems to be in contradiction with the definition (from the documentation):
If `'percent'` , the output of `histfunc` for a given bin is divided by the sum of the output of `histfunc` for all bins and multiplied by 100.
There is no mention of color or any other parameter affecting that calculation.

Is there a way to ensure that colors can be used together with a meaningful β€œall-data” histnorm?

Also, does anyone know why the pattern_shape is not working? I’m using Plotly 5.10

I realise this is an old post but I had this exact issue today and could not find a solution anywhere. Honestly, I am not sure why this is not a functionality.

Eventually I released that the default β€˜count’ is actually the exact behaviour we want and we can just redefine the y-axis ticks to get the correct percentages. The only issue is that this does not work for the hover text as it will still show the count and not the percentage.

If you did want the percentage then the only way would be to manually calculate the histogram percentages and then create individual bar plots.

fig = px.histogram(df, x='Value', color='Category')

total_count = len(df) # Total number of observations
step_size = 10 # Step size for nice percentage steps

# Generate tickvals and ticktext for nice percentage steps
tickvals = [(total_count * i) / 100 for i in range(0, 100 + 1, step_size)]
ticktext = [f'{i}%' for i in range(0, 100 + 1, step_size)]

# Update layout: modify y-axis tick labels to show nice percentage steps
fig.update_layout(
    yaxis=dict(
        title='Percentage',
        tickmode='array',
        tickvals=tickvals,
        ticktext=ticktext
    )
)

fig.show()