You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Stacked barplot missing certain groups that have non-missing values in the data #5428
Every week should have bars that total 100% and they do indeed in the data. They also do when you click on one of the commanders that has missing data. For example, when you click on Tiamat, the focused bar plot shows that it does have values for savedate_week = '2025-02-03'. And when you click on Ureni of the Unwritten, it has a value for savedate_week = '2025-06-16'. But both these values are missing from the overall stacked barplot.
I would like to work on this ISSUE #5428 and help fix the problem with stacked bar plots missing certain groups. I’ll start by reproducing the bug locally and investigating the data aggregation in plotly.express.bar.
I have reproduced the stacked barplot bug locally using the provided example_plot_data.csv.
The issue occurs because plotly.express.bar does not display groups that have missing values for certain weeks in the dataset.
To fix this, I generated all combinations of savedate_week and commanders and filled missing commander_perc_of_card values with 0. This ensures that all groups appear in the stacked barplot.
Before
After
Code:
importpandasaspdimportplotly.expressaspxfromitertoolsimportproduct# Load the dataplot_data=pd.read_csv("example_plot_data.csv")
plot_data['savedate_week'] =pd.to_datetime(plot_data['savedate_week'])
# Get all unique weeks and commandersall_weeks=plot_data['savedate_week'].unique()
all_commanders=plot_data['commanders'].unique()
# Generate full combinations of weeks and commandersfull_index=pd.DataFrame(list(product(all_weeks, all_commanders)), columns=['savedate_week','commanders'])
# Merge with original data and fill missing values with 0plot_data_full=full_index.merge(plot_data, on=['savedate_week','commanders'], how='left')
plot_data_full['commander_perc_of_card'] =plot_data_full['commander_perc_of_card'].fillna(0)
# Create the stacked barplotfig=px.bar(
plot_data_full,
x="savedate_week",
y="commander_perc_of_card",
color="commanders"
)
fig.show()
Activity
AJSTYLE-lab commentedon Jan 15, 2026
Hi @camdecoster,
I would like to work on this ISSUE #5428 and help fix the problem with stacked bar plots missing certain groups. I’ll start by reproducing the bug locally and investigating the data aggregation in plotly.express.bar.
Thank you!
AJSTYLE-lab commentedon Jan 15, 2026
Hi @camdecoster,
I have reproduced the stacked barplot bug locally using the provided
example_plot_data.csv.The issue occurs because
plotly.express.bardoes not display groups that have missing values for certain weeks in the dataset.To fix this, I generated all combinations of
savedate_weekandcommandersand filled missingcommander_perc_of_cardvalues with 0. This ensures that all groups appear in the stacked barplot.Before
After
Code:
camdecoster commentedon Jan 29, 2026
@jmaddalena would the workaround suggested by @AJSTYLE-lab get you past your issue?
emilykl commentedon Sep 2, 2026
Is this possibly the same root cause as #5324?