plotly / plotly/plotly.py

Animation deletes traces

Offen
#3,753 9 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug P3
Vorherrschende Sprache
Python
Sterne
18.8k
Forks
2.8k
Ø Merge
16 Std. 26 Min.
Gemergte PRs (30 T.)
21

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Führe zunächst das minimale Python-Beispiel aus und vergleiche das interaktive Ergebnis von fig.show() mit der gespeicherten plot.html. Untersuche Animationsframes und das Verhalten des Sliders, einschließlich des verschwindenden Grid-Traces, der gemeinsamen Markergröße und des unterschiedlichen Autoplay-Verhaltens; abgeschlossen ist die Aufgabe, wenn die beobachteten Verhaltensweisen erklärt und der bestätigte Bug korrigiert sind, ohne die anderen Traces zu beschädigen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
data-visualization
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.