Stacked Area Chart Not Showing Correct Values

I have a time series data set with values that I need to stack based on a ‘year_group’ column. Keep in mind the that ‘year_group’ is independent of the date column - it’s basically the start date for that item. Here is what the data looks like:

When I create a Plotly Express Area Chart, everything looks great at first glance. Where things get strange is the final group (year 2026) is at the top of each stack, even though there are not any values for that group until 2026.

If I unselect 2026, the same top line overlay then happens with 2025.

What I want to see on hover is the total amount for all stacks combined (which is represented correctly on the y-axis) and the amount for that specific ‘year_group’. I’ve messed with color and line_group options with no luck.

Any ideas? Thanks!

chart = px.area(df, x='date', y='value', color='year_group', line_group='year_group')
1 Like