plotly.py
plotly.py copied to clipboard
Normalized Histogram with Marginal producing the wrong plot
trafficstars
Using plotly.express (px) to plot a Histogram with barnorm = 'percent' and marginal = 'histogram' produces a plot where the barnorm is ignored and the raw counts are plotted. I think the output should be a histogram with barnorm = 'percent' and a marginal histogram with the regular counts.
px.histogram(pd.DataFrame({'x': np.random.normal(0, 1, 100),
'col': np.random.choice(['A', 'B'], 100)}),
x='x', color='col', barnorm='percent', marginal='histogram')
It's working if you use the following code:
import plotly.express as px
import pandas as pd
import numpy as np
df = pd.DataFrame({
'x': np.random.normal(0, 1, 100),
'col': np.random.choice(['A', 'B'], 100)
})
fig = px.histogram(df,
x='x',
color='col',
barnorm='percent',
marginal='rug'
)
fig.show()
The rug marginal is different than the histogram marginal in this case. My issue is when the same marginal as the plot (histogram in my code example) is used, the barnorm parameter is ignored.