I’m creating an animated plot of Scatter
frames laid over a Contour
. Both of these work fine when separate. But if I try to put them on the same figure, the background Contour
disappears after the first frame. I’m not the first one to deal with this:
Unfortunately, their suggestions did not help. I tried adding a “decoy” trace in data
. I tried adding frames + 1
clones of the background. I tried with an empty trace. Empty trace of Scatter
type. Tried with and without traces = [1]
in the frame. Tried setting it to 2 and 0. Swapping orders of “decoy” and normal traces. Nothing worked. It always did the same thing: show up on the first frame and then disappear.
Something that I have noticed is that all of them has the same type of base and frame plots. Mine are different. Could that be the problem? They are compatible with each other if I don’t try to animate them.
Code used to generate the files:
figure = plotly.graph_objects.Figure(
data=[
plotly.graph_objects.Scatter(x=[], y=[], showlegend=False),
plotly.graph_objects.Contour(
x=frame["x"],
y=frame["y"],
z=numpy.log10(frame["z"]),
),
],
frames=[
plotly.graph_objects.Frame(
data = plotly.graph_objects.Scatter(
x = [particle["x"] for particle in frame],
y = [particle["y"] for particle in frame],
mode="markers",
),
traces=[1]
) for frame in frames
],
)
figure.update_layout(width = 1500, height = 1500)
figure.write_html("fig.html")
frames
is a list of lists of dictionaries containing x, y
keys. frame
is a DataFrame
that represents a function: f(x, y) = z
Documentation for this part of the library is somewhat lacking, and examples I’ve found online hasn’t been helpful. Is this something I can do or should I look into different solutions?