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

Mesh3d plot disappears when opacity less than 1 #1565

Open
waynemystir opened this issue May 14, 2019 · 2 comments
Open

Mesh3d plot disappears when opacity less than 1 #1565

waynemystir opened this issue May 14, 2019 · 2 comments
Labels
bug something broken P3 backlog

Comments

@waynemystir
Copy link

waynemystir commented May 14, 2019

NOTE: When I found and reported this bug, I was working on a Chromebook. After I wrote this, I noted this does not occur from Mac with Chrome (ver 74).

Please see my example code below. I am plotting offline. When I change the opacity to anything other than 1, the plot disappears. As evidenced by the hover info, the plot still exists; it's just not visible.

I tried a number of different colorscales with different alpha values. The result does not change.

I also tried working around the opacity issue by setting the opacity to 1 and then setting the colorscale alpha values to something less than 1. But the alpha values appear to have no effect.

I noticed some similar bugs such as 3741, 3744, and 3492. Despite their similarity, these bugs appear to be different from this issue I am reporting. They are also resolved.

Lastly, I note that this bug occurs on the latest versions of Chrome (i.e. 74). But it does not occur on earlier versions.

Postscript: I have subsequently noticed the occurrence of the same opacity bug for Scatter3d. I also note that there's no opacity problem for Scatter in 2d.

import numpy as np
from numpy import sin, cos, pi
import plotly
import plotly.graph_objs as go

def ellipsoid( a = 4, b = 3, c = 2, num_pts = 40):
    phi = np.linspace(0, 2 * pi, num=num_pts)
    theta = np.linspace(-pi / 2, pi / 2, num=num_pts)
    phi, theta = np.meshgrid(phi, theta)
    x = cos(theta) * sin(phi) * a
    y = cos(theta) * cos(phi) * b
    z = sin(theta) * c

    Ell = np.vstack((x.flatten(), y.flatten(), z.flatten()))

    ell_1 = go.Mesh3d(
        opacity = 0.99,
        colorscale = [ [0.0, 'rgb(255, 0, 0)'], [0.5, 'rgb(0, 255, 0)'], [1.0, 'rgb(0, 0, 255)'] ],
        intensity = z.flatten(),
        name = 'z',
        showscale = False,
        x = Ell[0, :].flatten(),
        y = Ell[1, :].flatten(),
        z = Ell[2, :].flatten(),
        alphahull = 0
    )
    axes_max = np.max( np.abs(Ell) )
    return ell_1, axes_max

def plot_it(data, mr):
    r = [-mr, mr]
    layout = go.Layout(
        autosize = False,
        width = 600,
        height = 600,
        margin = dict(
            l = 0,
            r = 0,
            b = 0,
            t = 0,
            pad = 4),
        scene = dict(
            aspectratio = go.layout.scene.Aspectratio(x=1, y=1, z=1),
            xaxis = dict(
                range=r,
                title='x'),
            yaxis = dict(
                range=r,
                title='y'),
            zaxis = dict(
                range=r,
                title='z' ))
    )

    fig = go.Figure(data=data, layout=layout)
    plotly.offline.plot(fig, filename='/home/chronos/user/Downloads/bug_mesh3d_opac.html')
    return

def test1():
    d, mx = ellipsoid()
    data = [d]
    plot_it(data, mx+2.)
    return

def main():
    test1()
    return

if __name__ == "__main__":
    main()
@waynemystir waynemystir changed the title Mesh3D plot disappears when opacity less than 1 Mesh3d plot disappears when opacity less than 1 May 14, 2019
@jonmmease
Copy link
Contributor

Hi @waynemystir, thanks for the report. This is something that will need to be discussed in the plotly.js project at https://github.com/plotly/plotly.js/issues.

Do any of the plotly.js documentation examples at https://plot.ly/javascript/3d-mesh/ show the problem? If so, could you open an issue in the plotly.js project referencing the documentation example and the details of all of the browsers you've tried?

If not, could you see if you can reproduce the behavior in plotly.js by modifying one of the CodePen examples there (click the "Edit on CodePen" button in the top-right of the example)? Thanks!

@Devchonka
Copy link

I can confirm this issue, the regression occurred in one of the more recent Plotly releases.

@gvwilson gvwilson self-assigned this Jun 13, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson added P3 backlog bug something broken labels Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P3 backlog
Projects
None yet
Development

No branches or pull requests

4 participants