Skip to content

zorder doesn't work on version 5.21.0 #4583

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
khisr0w opened this issue Apr 21, 2024 · 5 comments
Closed

zorder doesn't work on version 5.21.0 #4583

khisr0w opened this issue Apr 21, 2024 · 5 comments

Comments

@khisr0w
Copy link

khisr0w commented Apr 21, 2024

The zorder attribute was added recently. However, the following code does not work as expected (exact code as here):

import plotly
import plotly.graph_objects as go

fig = go.Figure(
    go.Bar(
        x=[0, 1, 2],
        y=[1, 2, 3]
    ),
)
fig.add_trace(
    go.Scatter(
        x=[0, 1, 2],
        y=[3, 2, 1],
        zorder=-2
    )
)

fig.update_layout(
    title=dict(text=f"{plotly.__version__ = }")
)
fig.show()

Expected Behavior: Bar chart should have a higher z-order, meaning it should be at the front.
Instead, the code produces the following:
image

@Farkites
Copy link

Hi @khisr0w I'm not able to reproduce the issue that you have mentioned. Using your code I get the behaviour is as expected:
newplot (3)

@LiamConnors
Copy link
Member

@khisr0w are you running this in VSCode? What version of Plotly.js do you see if you hover over the Plotly logo in the corner?

image

@khisr0w
Copy link
Author

khisr0w commented Apr 22, 2024

@LiamConnors As a matter of fact, yes. The JS version seems to lower than what is shown in your case:
image
Is there a specific issue with VS Code?

@LiamConnors
Copy link
Member

@khisr0w yeah, it can be an issue in VS Code as by default it uses its own bundled version of Plotly.js

This page gives a bit more detail.
https://plotly.com/python/troubleshooting/#vscode-notebook-nteract-and-streamlit-problems

If you call fig.show while setting the renderer to 'notebook', it should use the Plotly.py install version instead.

fig.show(renderer='notebook')

@khisr0w
Copy link
Author

khisr0w commented Apr 22, 2024

Worked like a charm. Thanks, @LiamConnors :)

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

No branches or pull requests

3 participants