Skip to content

Some charts rendering differently on master branch vs Plotly.py 5.24.1 #4863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
LiamConnors opened this issue Nov 12, 2024 · 1 comment · Fixed by #4865
Closed

Some charts rendering differently on master branch vs Plotly.py 5.24.1 #4863

LiamConnors opened this issue Nov 12, 2024 · 1 comment · Fixed by #4865
Assignees
Labels
bug something broken P1 needed for current cycle

Comments

@LiamConnors
Copy link
Member

LiamConnors commented Nov 12, 2024

There are a few charts that show differently with what's on master branch vs the latest release of Plotly.py:

1. Histogram with px

import plotly.express as px
tips = px.data.tips()
fig = px.histogram(
    tips, x="total_bill", y="tip", color="sex", marginal="rug", hover_data=tips.columns
)
fig.show()

5.24.1:

Image

Master branch:

Image

2. Timeline with px

import pandas as pd
import plotly.express as px
df = pd.DataFrame(
    [
        dict(Task="Job A", Start="2009-01-01", Finish="2009-02-28"),
        dict(Task="Job B", Start="2009-03-05", Finish="2009-04-15"),
        dict(Task="Job C", Start="2009-02-20", Finish="2009-05-30"),
    ]
)
fig = px.timeline(df, x_start="Start", x_end="Finish", y="Task", color="Task")
fig.show()

5.24.1:

Image

Master branch:

Image

3. Scatter with px

iris = px.data.iris()
fig = px.scatter(
    iris,
    x="sepal_width",
    y="sepal_length",
    color="species",
    marginal_y="rug",
    marginal_x="histogram",
)
fig.show()

5.24.1:

Image

Master branch:

Image

@gvwilson gvwilson added bug something broken P1 needed for current cycle labels Nov 12, 2024
@emilykl
Copy link
Contributor

emilykl commented Nov 12, 2024

OK, I've confirmed that at least the histogram case is indeed a result of plotly/plotly.js#7009.

Before 7009, when barmode was set to relative, the offsetgroup property of traces was ignored (as far as I am aware). 7009 introduced a change where offsetgroup is applied in relative barmode (and bars with the same category-axis value and offsetgroup are stacked), which has the effect that if two traces have different offsetgroup values, they appear as grouped bars even if barmode is set to relative or stacked.

This caused the change in behavior we are seeing for histograms, since px assigns an offsetgroup to each trace when creating the figure object.

Maybe the fix is as simple as removing offsetgroup from the traces in the generated figure object -- I'm not sure whether there's a reason for it to be there; still investigating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P1 needed for current cycle
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants