plotly / plotly/plotly.py

go.Scatter3d doesn't display a given tensor

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

还没有人认领这个 Issue。

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

描述

Issue

While plotting an np.ndarray of type fp64, it is not displayed.
It is so funny that we could reproduce it only for one specific array.

Thigs that make the script work:

  • If we add epsilon (as in the commented line), then the pointcloud is displayed properly.
  • If we cast to fp32 it works.
  • If we add a small value (0.000000000001 for example), it works.

Things that doesn't work:

  • If we add or substract big values, like 0.4, 1 or 2, it doesn't work
  • If we substract epsilon, it doesn't work
  • if we add numbers larger than 0.000000000001, it doesnt' work even if tehy are small (0.000001 for example)

Environment

We tried this (and reproduced in at least 2 computers) with numpy 1.26.3 and plotly 5.18.0 on ubuntu 22

import numpy as np
import plotly.graph_objects as go

init = np.array(
    [
        [
            -0.063,
            -0.063,
            0.0,
        ],
        [
            -0.063,
            -0.021,
            0.0,
        ],
        [
            -0.063,
            0.021,
            0.0,
        ],
        [
            -0.063,
            0.063,
            0.0,
        ],
        [
            -0.021,
            -0.021,
            0.0,
        ],
        [
            -0.021,
            -0.063,
            0.0,
        ],
        [
            -0.021,
            0.021,
            0.0,
        ],
        [
            -0.021,
            0.063,
            0.0,
        ],
        [
            0.021,
            -0.063,
            0.0,
        ],
        [
            0.021,
            -0.021,
            0.0,
        ],
        [
            0.021,
            0.021,
            0.0,
        ],
        [
            0.021,
            0.063,
            0.0,
        ],
        [
            0.063,
            -0.063,
            0.0,
        ],
        [
            0.063,
            -0.021,
            0.0,
        ],
        [
            0.063,
            0.021,
            0.0,
        ],
        [
            0.063,
            0.063,
            0.0,
        ],
    ]
)

rot_mat = [
    [4.93038066e-32, -1.00000000e00, 2.22044605e-16],
    [2.22044605e-16, 2.22044605e-16, 1.00000000e00],
    [-1.00000000e00, 0.00000000e00, 2.22044605e-16],
]

transformed = (rot_mat @ init.T).T + np.array([0.5, 0.5, 0.5])


x, y, z = 0, 1, 2
idx = list(transformed.shape).index(3)
if idx < 0:
    raise ValueError("Array must be [X,Y,Z] x N")
elif idx == 1:
    array = transformed.transpose()

default_kwargs = dict(
    mode="markers",
    marker=dict(size=3, color="black"),
)

print(array.dtype)

# array[y]+=np.finfo(np.float64).eps
print(array.dtype)
print(array)
plot = go.Scatter3d(x=array[x], y=array[y], z=array[z], **default_kwargs)

default_kwargs = dict(
    scene=dict(
        xaxis=dict(title="X", range=[0, 2]),
        yaxis=dict(title="Y", range=[0, 2]),
        zaxis=dict(title="Z", range=[0, 2]),
    ),
)
layout = go.Layout(**default_kwargs)

fig = go.Figure(data=plot, layout=layout)

fig.show()

贡献指南

打开贡献指南

从这里开始

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

调研方向

使用提供的复现脚本作为入口,并在 Ubuntu 22 上使用 numpy 1.26.3 和 plotly 5.18.0 运行它。将失败的 fp64 数组与正常工作的 epsilon 和 fp32 变体进行比较,然后跟踪 go.Scatter3d 的渲染路径。完成标准是确定原因,并添加一个回归检查来显示给定张量能够被显示。

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

评估

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

把新 issue 发到你的邮箱

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