Skip to content

slight change in surface opacity changes image completely #2690

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
paddyroddy opened this issue Aug 5, 2020 · 7 comments
Closed

slight change in surface opacity changes image completely #2690

paddyroddy opened this issue Aug 5, 2020 · 7 comments

Comments

@paddyroddy
Copy link

I need to adjust the opacity of a surface, so I can overlay two surfaces on top of each other (not sure how else to do that). But on a very small change from 1 to slightly below the look of the plot changes a lot.

opacity=1
image

opacity=0.99999
image

import numpy as np
from plotly.graph_objs import Figure, Surface

x = np.array(
    [
        [0, 0, 0, 0, 0, 0, 0, 0, 0],
        [
            7.07106781e-01,
            0.5,
            4.32978028e-17,
            -0.5,
            -7.07106781e-01,
            -0.5,
            -1.29893408e-16,
            0.5,
            7.07106781e-01,
        ],
        [
            1,
            7.07106781e-01,
            6.12323400e-17,
            -7.07106781e-01,
            -1,
            -7.07106781e-01,
            -1.83697020e-16,
            7.07106781e-01,
            1,
        ],
        [
            7.07106781e-01,
            0.5,
            4.32978028e-17,
            -0.5,
            -7.07106781e-01,
            -0.5,
            -1.29893408e-16,
            0.5,
            7.07106781e-01,
        ],
        [
            1.22464680e-16,
            8.65956056e-17,
            7.49879891e-33,
            -8.65956056e-17,
            -1.22464680e-16,
            -8.65956056e-17,
            -2.24963967e-32,
            8.65956056e-17,
            1.22464680e-16,
        ],
    ]
)
y = np.array(
    [
        [0, 0, 0, 0, 0, -0, -0, -0, 0],
        [0, 0.5, 7.07106781e-01, 0.5, 8.65956056e-17, -0.5, -7.07106781e-01, -0.5, 0],
        [
            0,
            7.07106781e-01,
            1,
            7.07106781e-01,
            1.22464680e-16,
            -7.07106781e-01,
            -1,
            -7.07106781e-01,
            0,
        ],
        [0, 0.5, 7.07106781e-01, 0.5, 8.65956056e-17, -0.5, -7.07106781e-01, -0.5, 0],
        [
            0,
            8.65956056e-17,
            1.22464680e-16,
            8.65956056e-17,
            1.49975978e-32,
            -8.65956056e-17,
            -1.22464680e-16,
            -8.65956056e-17,
            0,
        ],
    ]
)
z = np.array(
    [
        [1, 1, 1, 1, 1, 1, 1, 1, 1],
        [
            7.07106781e-01,
            7.07106781e-01,
            7.07106781e-01,
            7.07106781e-01,
            7.07106781e-01,
            7.07106781e-01,
            7.07106781e-01,
            7.07106781e-01,
            7.07106781e-01,
        ],
        [
            6.12323400e-17,
            6.12323400e-17,
            6.12323400e-17,
            6.12323400e-17,
            6.12323400e-17,
            6.12323400e-17,
            6.12323400e-17,
            6.12323400e-17,
            6.12323400e-17,
        ],
        [
            -7.07106781e-01,
            -7.07106781e-01,
            -7.07106781e-01,
            -7.07106781e-01,
            -7.07106781e-01,
            -7.07106781e-01,
            -7.07106781e-01,
            -7.07106781e-01,
            -7.07106781e-01,
        ],
        [-1, -1, -1, -1, -1, -1, -1, -1, -1],
    ]
)
data = [Surface(x=x, y=y, z=z, surfacecolor=np.ones(x.shape), opacity=0.99999)]
fig = Figure(data=data)
fig.show()

sorry about the numbers, they've been generated by some external library

my actual use case is like this where there are weird lines appearing on the plot by setting opacity
image

@nicolaskruchten
Copy link
Contributor

@archmoj can you comment please?

@archmoj
Copy link
Contributor

archmoj commented Aug 6, 2020

@paddyroddy could you please set the opacity to 0.25 or 0.5 and share new screenshots?

@paddyroddy
Copy link
Author

opacity=0.5
image

and in my more complicated use-case with opacity=0.5
image

@archmoj
Copy link
Contributor

archmoj commented Aug 6, 2020

Here is a demo in codepen.
Wondering if you tried using mesh3d instead of surface plot for that kind of geometry?

@archmoj
Copy link
Contributor

archmoj commented Aug 6, 2020

This could possibly be fixed/improved by plotly/plotly.js#4643.
But at the moment I don't see that PR being merged in near feature.

@paddyroddy
Copy link
Author

Here is a demo in codepen.
Wondering if you tried using mesh3d instead of surface plot for that kind of geometry?

thanks, no I haven't. My actual data is spherical (the example was low resolution) and isn't one uniform colour I have a surfacecolor passed to it. So not sure whether mesh3d would achieve the same thing

@gvwilson
Copy link
Contributor

Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for several years, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Thanks for your help - @gvwilson

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

4 participants