Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Syncing Axes Ticks does not work in 5.16.1 #4351

Open
Labels
P3backlog bugsomething broken regressionthis used to work
@seanslma

Description

Copied the code from: https://plotly.com/python/multiple-axes/?_gl=1*wwvkz4*_ga*MTg4OTU0MjQ0NS4xNjgwMTUyOTc1*_ga_6G7EE0JNSC*MTY5NDM5NDQ0OC4zNC4xLjE2OTQzOTkyMjcuNjAuMC4w#sync-axes-ticks

After running the code in 5.16.1, the numbers of yticks for y and y2 are not the same:

import plotly.graph_objects as go
from plotly.data import tips
df = tips()
summed_values = df.groupby(by="day", as_index=False).sum(numeric_only=True)
day_order_mapping = {"Thur": 0, "Fri": 1, "Sat": 2, "Sun": 3}
summed_values["order"] = summed_values["day"].apply(lambda day: day_order_mapping[day])
summed_values = summed_values.sort_values(by="order")
days_of_week = summed_values["day"].values
total_bills = summed_values["total_bill"].values
number_of_diners = summed_values["size"].values
fig = go.Figure(
 data=go.Bar(
 x=days_of_week,
 y=number_of_diners,
 name="Total number of diners",
 marker=dict(color="paleturquoise"),
 )
)
fig.add_trace(
 go.Scatter(
 x=days_of_week,
 y=total_bills,
 yaxis="y2",
 name="Total bill amount",
 marker=dict(color="crimson"),
 )
)
fig.update_layout(
 legend=dict(orientation="h"),
 yaxis=dict(
 title=dict(text="Total number of diners"),
 side="left",
 range=[0, 250],
 ),
 yaxis2=dict(
 title=dict(text="Total bill amount"),
 side="right",
 range=[0, 2000],
 overlaying="y",
 tickmode="sync",
 ),
)
fig.show()

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlog bugsomething broken regressionthis used to work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /