Skip to content

Order of traces affects visibility in Scatter3d #1030

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
ivirshup opened this issue Jun 8, 2018 · 2 comments
Closed

Order of traces affects visibility in Scatter3d #1030

ivirshup opened this issue Jun 8, 2018 · 2 comments

Comments

@ivirshup
Copy link
Contributor

ivirshup commented Jun 8, 2018

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

@jonmmease
Copy link
Contributor

Hi @ivirshup, thanks for the report.

I've opened a corresponding issue in the plotly.js project (plotly/plotly.js#2717), which is where the actual plot rendering logic lives. I'm going to close this issue, and we can continue the conversation with the plotly.js devs over there.

@jonmmease
Copy link
Contributor

Updated issue: plotly/plotly.js#1267

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

2 participants