plotly / plotly/plotly.py

fig.add_vline fails on figure with a separate subplot containing Scatter3d

Open
#3,874 2 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

The following code creates a 2D subplot in the left column and a 3D subplot in the right column. Adding a vertical line to the 2D subplot fails if a Scatter3d has been added to the 3D subplot.

Another bug shown in this example is that add_vline does not add any annotations if the plot is empty.

from plotly import subplots
specs = [
    [{}, {'type': 'scene', 'rowspan': 1}],
]
fig = subplots.make_subplots(rows=1, cols=2, specs=specs)

# Add dummy data 
# If both of these are commented out, fig.add_vline does nothing
# If neither are commented out, fig.add_vline raises a PlotlyKeyError
# If fig.add_scatter3d is commented out, the figure is generated successfully
fig.add_scatter(x=[0, 1], y=[0, 1], row=1, col=1)
fig.add_scatter3d(x=[0, 1], y=[0, 1], z=[0, 1], row=1, col=2)

# Add vertical line to left (2D) subplots only
fig.add_vline(x=2, col=1)  # Raises PlotlyKeyError

(Plotly version 5.9.0)

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 provided make_subplots, add_scatter3d, and add_vline example first, including the three data configurations shown. Trace the add_vline entry point and its handling of 2D and scene subplots; done means the 2D vertical line no longer raises PlotlyKeyError and empty plots receive annotations.

Written by the indexing model from the issue text.

Assessment

Tech stack
plotly, python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.