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

select_traces returns all traces when selector=0 #3639

Closed
dmpozharskiy opened this issue Mar 23, 2022 · 0 comments · Fixed by #3817
Closed

select_traces returns all traces when selector=0 #3639

dmpozharskiy opened this issue Mar 23, 2022 · 0 comments · Fixed by #3817

Comments

@dmpozharskiy
Copy link

The select_traces function fetches all traces when using selector=0.

The bug is at https://github.com/plotly/plotly.py/blob/master/packages/python/plotly/plotly/basedatatypes.py#L1144 where the selector is overwritten by an empty dict in this case.

A minimum code snippet is:

fig = go.Figure()
fig.add_trace(go.Scatter(x=[0, 1], y=[0, 1], name="trace0"))
fig.add_trace(go.Scatter(x=[0, 1], y=[0, 1], name="trace1"))

for trace in fig.select_traces(selector=0):
    print(trace["name"])
    
for trace in fig.select_traces(selector=1):
    print(trace["name"])

The output is:

trace0
trace1

trace1
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

Successfully merging a pull request may close this issue.

1 participant