Skip to content

slight change in surface opacity changes image completely #2690

Closed
@paddyroddy

Description

@paddyroddy

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

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