Skip to content

Order of traces affects visibility in Scatter3d #1030

Closed
@ivirshup

Description

@ivirshup

For 3d scatter plots with opacity < 1, the last trace to be added always shows up on top, regardless of camera position.

import numpy as np
from itertools import product

import plotly.graph_objs as go
import plotly.offline as py
py.init_notebook_mode(connected=True)

# Gen data
n = 10
r = np.arange(n)
a1 = np.zeros((n*n, 3))
a2 = np.zeros((n*n, 3))
for i, (x, y) in enumerate(product(r, r)):
    a1[i, :] = (x, y, -1)
    a2[i, :] = (x, y, 1)

# Gen traces
traces = list()
for i, a in enumerate((a1, a2)):
    trace = go.Scatter3d(
        x = a[:, 0],
        y = a[:, 1],
        z = a[:, 2],
        mode="markers",
        marker=dict(
            opacity=.99
        )
    )
    traces.append(trace)

# Plot
fig = go.Figure(data=traces)
py.iplot(fig)

When trace 1 should be on top:

screen shot 2018-06-08 at 2 47 07 pm

When trace 0 should be on top:

screen shot 2018-06-08 at 2 47 19 pm

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