Animation deletes traces
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 2.8k
- Avg merge
- 16h 26m
- Merged PRs (30d)
- 21
Description
Below is a minimal example, where using a slider to show different traces will delete another trace.
The example plots a grid of points and uses a slider to interactively display selected rows, however, the original grid plot disappears as soon as the slider is moved.
This looks like a bug to me. If it’s not, how can I prevent that trace from disappearing?
import numpy as np
import plotly.graph_objects as go
# generate grid
N = 10
x, y = np.meshgrid(np.linspace(0, 1, N), np.linspace(0, 1, N))
z = np.zeros((N, N))
# plot
fig = go.Figure(
# all points (THIS DISAPPEARS!)
data=[go.Scatter3d(x=x.flatten(), y=y.flatten(), z=z.flatten())],
# single rows animated via slider
frames=[go.Frame(data=[go.Scatter3d(x=x[i], y=y[i], z=z[i])], name=f"{i}") for i in range(N)],
layout_sliders=[dict(steps=[dict(method='animate', args=[[f"{k}"]], label=f"{k}") for k in range(N)])])
fig.write_html('plot.html')
fig.show()
Two other weird things (potential bugs), which might be unrelated:
- Setting a marker size on the first trace also changes the marker size of the animated traces. Should that be the case?!
- The interactively opened plot behaves differently from opening the saved html plot (the second one starts playing the animation right away, the first one doesn’t).
I have also posted this in the community forum but without any reactions so far.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the minimal Python example and compare the interactive fig.show() result with the saved plot.html. Investigate animation frames and slider behavior, including the disappearing grid trace, shared marker size, and differing autoplay behavior; done means the observed behaviors are explained and the confirmed bug is corrected without breaking the other traces.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100