plotly / plotly/plotly.py

rendering problems with mesh3d and logarithmic zaxis

Open
#3,674 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3
Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
16h 26m
Merged PRs (30d)
21

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the supplied Python example with plotly.graph_objects.Mesh3d and compare the linear and logarithmic z-axis renders. Start by tracing Mesh3d rendering with logarithmic scene axes; done means the complete set of 3D bars renders correctly with the logarithmic z-axis, while preserving the linear-axis behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.