plotly / plotly/plotly.js

aspectmode=data is incorrect when cones and scatter points are both involved

Open
#7,143 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

See https://codepen.io/alexcjohnson/pen/ExBryzb?editors=0010

When all traces in this plot are shown, the square is not square:
Screenshot 2024-09-08 at 17 58 11

But if you click the legend to hide the cone trace, you do get a square:
Screenshot 2024-09-08 at 17 58 36

This is a pretty important bug for anyone making a plot representing real 3D space, as shapes will be distorted and the only workaround I could find is to abandon axis autorange: set explicit ranges for all three axes, set aspectmode: 'manual', and calculate aspectratio.{x, y, z} explicitly.

I haven't been able to reproduce this issue with only scatter3d traces, nor have I tried with other trace types or with just cones, but my guess is we're calculating the axis aspect ratios before adding extra padding to the ranges to accommodate the cones. Ironically it appears we don't pad the axes (not at all? not very much? I can't quite tell) for scatter3d points, but that's a separate issue.

As a side note: it would be nice if aspectratio or aspectmode docs stated that aspectratio is ignored when you set aspectmode: 'data'. I've seen users try to use this combination of attributes to create vertical exaggeration of topography, but this fails (and again, the only solution I can find is to calculate everything manually).

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

Start with the linked CodePen reproduction and trace how 3D aspectmode:'data' handles axis ranges when cone and scatter3d traces are both visible. Compare the result with the cone hidden; done means the square remains square with both traces shown and the aspectratio/aspectmode documentation explains the reported limitation.

Written by the indexing model from the issue text.

Assessment

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