Bug report / On px.histogram's histnorm parameter

Consider the following toy example:

import pandas as pd
import plotly.express as px

df_test = pd.DataFrame([1,1,1,1,2,2,2,3,3,4,4,4,4,4,5,5,5,5,5,5], columns=[‘Test’])
fig = px.histogram(df_test, x=‘Test’, histnorm=None)

  1. The y-axis is labeled ‘count’ whatever histnorm parameter chosen. I don’t think that should be the case, especially if histnorm=‘percent’ or histnorm=‘probability’.

  2. It seems to me that ‘None’ and ‘density’ yield exactly the same graph, can somebody give me an example where it makes a difference? Same for ‘probability’ and ‘probability density’.

Hello @LordFinzenz

  1. It’s True that it would be better to display the name of the histnorm, we have an open issue for this https://github.com/plotly/plotly_express/issues/122, please bear with us until this is implemented.

  2. In your example the bins have a width of 1, hence there is no difference between the two modes (with density, the count or histfunc is divided by the width of the bin). With the following example you’ll see a difference

import pandas as pd
import plotly.express as px
import numpy as np

df_test = pd.DataFrame(np.random.random(1000), columns=['Test'])
fig = px.histogram(df_test, x='Test', histnorm=None) # change to 'density' here
1 Like