plotly / plotly/plotly.py

Mesh3d plot disappears when opacity less than 1

未关闭
#1,565 2 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

bug P3
主要语言
Python
星标
18.8k
派生
2.8k
平均合并
16 小时 26 分钟
30 天内合并 PR
21

描述

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()

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

使用 plotly.offline.plot 和 Mesh3d trace 在 Chrome 中重现该示例,改变 opacity 和 colorscale 的 alpha 值;同时检查报告的 Scatter3d 情况。跟踪 3D 渲染路径,以确定几何体为何仍可 hover 但不可见,并在半透明的 Mesh3d 和 Scatter3d 图表能够正确渲染时将 issue 视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
data-visualization
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
38/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。