Skip to content

Mix of Scatter and Scattergl - Scattergl is always on top #1514

Closed
@wdobbels

Description

@wdobbels

A typical use case for me is to have a bunch of scatterpoints (need Scattergl), and then fit a line through them (ideally with normal Scatter). However, no matter the order of the traces, Scattergl always seems to end on top (and hence the line disappears below the scatter points). Ideally, the order of the traces should be retained (no matter if it's a Scatter or Scattergl). Even better would be a zorder parameter (as in matplotlib), where we don't need to worry about the order in which we add the traces to the data.

Here's some code to reproduce the bug:

import plotly.offline as py
import plotly.graph_objs as go

trace_scatter = go.Scattergl(x=[1, 2, 3, 4], y=[1, 2, 3, 4], mode='markers')
trace_line = go.Scatter(x=[1, 4], y=[1, 4], mode='lines')
# line trace is placed last, so should end up top - but it doesn't
data = [trace_scatter, trace_line]
py.iplot(data)

If Scattergl is replaced by Scatter, the line is correctly drawn up top. I tested this in offline mode but assume the same is true in online mode. I'm new to plotly so I don't know enough about its inner workings to do a pull request right now (if really needed, with some pointings in the right direction, I could take a look).

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