plotly / plotly/plotly.py

rendering problems with mesh3d and logarithmic zaxis

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

还没有人认领这个 Issue。

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

描述

I'm trying to visualize a 3D bar chart, in which I need a logarithmic z-axis. However, I've stumbled upon a rendering problem: only the top size of the cube is rendered.

import numpy as np
import plotly.graph_objects as go

Percentage_Differences_1 = np.array([ [7.94*(10**-10),7.94*(10**-9),7.94*(10**-8),7.94*(10**-7),7.94*(10**-6),7.94*(10**-5)],
                                [7.92*(10**-12),7.92*(10**-11),7.92*(10**-10),7.92*(10**-9),7.92*(10**-8),7.92*(10**-7)],
                                [7.72*(10**-14),7.72*(10**-13),7.72*(10**-12),7.72*(10**-11),7.72*(10**-10),7.72*(10**-9)],
                                [5.66*(10**-16),5.66*(10**-15),5.66*(10**-14),5.66*(10**-13),5.66*(10**-12),5.66*(10**-11)],
                                [1.49*(10**-17),1.49*(10**-16),1.49*(10**-15),1.49*(10**-14),1.49*(10**-13),1.49*(10**-12)],
                                [2.21*(10**-18),2.21*(10**-17),2.21*(10**-16),2.21*(10**-15),2.21*(10**-14),2.21*(10**-13)] ])

bar_verts = np.array([[0, 0, 0, 1],
[1, 0, 0, 1],
[1, 1, 0, 1],
[0, 1, 0, 1],
[0, 0, 1, 1],
[1, 0, 1, 1],
[1, 1, 1, 1],
[0, 1, 1, 1]], dtype=float).T
def translate(x, y, z):
    d = np.eye(4, dtype=float)
    d[:, -1] = [x, y, z, 1]
    return d
def scale(sx, sy, sz):
    d = np.eye(4, dtype=float)
    d[np.diag_indices(4)] = [sx, sy, sz, 1]
    return d

meshes = []
for xc in range(1,6):
    for yc in range(1,6):
        verts = np.matmul(translate(xc, yc, 0), bar_verts)
        verts = np.matmul(scale(1, 1, Percentage_Differences_1[xc][yc]), verts)

        x = verts[0, :]
        y = verts[1, :]
        z = verts[2, :]
        
        meshes.append(
            go.Mesh3d(
                x=x, y=y, z=z,
                # i, j and k give the vertices of triangles
                i = [7, 0, 0, 0, 4, 4, 6, 6, 4, 0, 3, 2],
                j = [3, 4, 1, 2, 5, 6, 5, 2, 0, 1, 6, 3],
                k = [0, 7, 2, 3, 6, 7, 1, 1, 5, 5, 7, 6],
                flatshading = True
            )
        )
fig = go.Figure(data=meshes, layout={
    "scene": {
        "zaxis": {
            "type": "log"
        }
    }
})
fig

Here is a screenshot: on the left, linear z axis. On the right, logarithmic z axis.
newplot

贡献指南

打开贡献指南

从这里开始

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

调研方向

使用 plotly.graph_objects.Mesh3d 复现所提供的 Python 示例,并比较线性和对数 z-axis 的渲染结果。首先跟踪使用对数 scene axes 时 Mesh3d 的渲染;当完整的 3D 柱集合能够通过对数 z-axis 正确渲染,同时保留线性轴的行为时,即表示完成。

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

评估

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

把新 issue 发到你的邮箱

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