Skip to content

select_traces returns all traces when selector=0 #3639

Closed
@dmpozharskiy

Description

@dmpozharskiy

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions