Skip to content

null values reset stacking in express barchart #5324

@bhogan-mitre

Description

@bhogan-mitre

It seems like null values in the middle of a series reset the stacking so that the next value starts at zero. I tried it upstream in a JS codepen and it is handled okay there, so I believe it is an issue with the python API or possibly with plotly.express.

Reprex modified from https://plotly.com/python/bar-charts/#bar-charts-with-text

import plotly.express as px

wide_df = px.data.medals_wide()

# set null value in middle 'silver' series
wide_df.iloc[0,2] = None

fig = px.bar(
  wide_df, 
  x="nation", 
  y=["gold", "silver", "bronze"], 
  title="Nulls Reset Stacking", 
  text_auto=True)

fig.show()

Output:

Image

Based on input data:

Image

Note that South Korea should be stacked to a total of 35 and not 24.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions