Iβm drawing multiple histograms or a bar charts using a loop. I need to make multiple figures to be able to set the legendgroup for each.
When I click on the legend to hide the top or bottom category it removes it entirely. This is what I want.
When I click to hide any of the categories in the middle, the bars disappear but they still leave a space for that category.
Can I make it so that the space is always removed along with the bar?
Code:
fig = go.Figure()
for subcategory in subcategory_order:
subcategory_df = df.loc[df['subcategory'] == subcategory]
fig.add_trace(go.Histogram(y=subcategory_df['subcategory'],
name=subcategory,
showlegend=True,
legendgroup=subcategory
))
fig.update_traces(orientation='h')
fig.show()
Result: