Skip to content
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

Adding secondary-y latex legend name shifts x-axis coordinates #4588

Open
cmgoold opened this issue Apr 25, 2024 · 0 comments
Open

Adding secondary-y latex legend name shifts x-axis coordinates #4588

cmgoold opened this issue Apr 25, 2024 · 0 comments

Comments

@cmgoold
Copy link

cmgoold commented Apr 25, 2024

Plotly version 5.20.0.

I am creating subplots with seconary y-axes. When I add the name attribute to a figure that includes a Latex string, the x-axis coordinates are incrementally shifted more and more to the right with each subplot. For instance, the first subplot in this image renders fine, but 2 through 4 are shifted right:

newplot (26)

This only happens when including the Latex string.

Here's a minimal working example:

import plotly.graph_objects as go
from plotly.subplots import make_subplots

x = [1, 2, 3, 4]
y = [1]*4

R = 1
C = 4

fig = make_subplots(
    rows=R,
    cols=C,
    specs=[
        [{"secondary_y": True} for _ in range(C)]
        for _ in range(R)
    ],
)

rc = [(r, c) for r in range(R) for c in range(C)]

for i, (r, c) in enumerate(rc):
    fig.add_trace(
        go.Scatter(
            x=x,
            y=y,
            showlegend=not i,
            name="y1",
        ),
        row=r+1,
        col=c+1,
        secondary_y=False,
    )
    fig.add_trace(
        go.Scatter(
            x=x,
            y=y,
            showlegend=not i,
            name=r"$y$2",
        ),
        row=r+1,
        col=c+1,
        secondary_y=False,
    )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants