plotly / plotly/plotly.js

Cone tips do not point at the correct positions

Open
#6,714 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P2
Dominant language
JavaScript
Stars
18.3k
Forks
2k
Avg merge
2d 12h
Merged PRs (30d)
28

Description

In the following, each of two vectors ends at the start of the next one. Tweaking the length of the cones in any way suited to examining them visually, they clearly do not point at the base of their successor cone as (naively?) expected. At least if we expect that the bases of the cones are centered to the start point of the vector it is representing.

import plotly.graph_objs as go
from numpy import array

points = [
    [array([-0.03620968,  0.24876811,  5.51279187]), array([1.39049627, 0.57429448, 4.67921793])],
    [array([1.39049627, 0.57429448, 4.67921793]), array([2.02424265, -0.15235655,  2.63707954])],
    [array([ 2.02424265, -0.15235655,  2.63707954]), array([ 3.68335955, -1.14431782,  1.09909298])]
]

cone_traces = []

for pair in points:
        start_point = pair[0]
        end_point = pair[1]
        vector = end_point - start_point

        # a partial workaround to scale the vectors more or less to their actual length, which
        # plottly does not allow fully controlling: https://github.com/plotly/plotly.js/issues/3613
        scaled_vector = vector * 1.5

        start_x, start_y, start_z = start_point[0], start_point[1], start_point[2]
        end_x, end_y, end_z = end_point[0], end_point[1], end_point[2]

        trace = go.Cone(
            x=[start_x],
            y=[start_y],
            z=[start_z],
            u=[scaled_vector[0]],
            v=[scaled_vector[1]],
            w=[scaled_vector[2]])
        cone_traces.append(trace)

layout = go.Layout(

    scene=dict(
        camera=dict(

            # set the virtual point of view to point to the origin
            center=dict(x=0, y=0, z=0),

            # set the virtual point of view to be positioned parallel to the depth axis, at a distance
            # sufficently away from the vectors to see them all; although plotly won't fully respect the
            # angle this eye position should make, https://stackoverflow.com/q/76q921229/1509695,
            # it will be very very close to that, and the chart user can nudge the tilt to
            # perfect the viewing angle.
            eye=dict(x=0, y=0, z=-3))))

fig = go.Figure(data=cone_traces, layout=layout)
fig.show()

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 go.Cone example, varying cone length and camera settings to confirm the positional discrepancy. Trace the corresponding plotly.js 3D cone rendering behavior and add a regression check for cone bases aligning with the supplied vector start points; done means the cones point to the expected successor positions.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, 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.