hannorein / rebound

💫 An open-source multi-purpose N-body code.
https://rebound.readthedocs.io/
GNU General Public License v3.0
820 stars 217 forks source link

Update on OrbitPlotSet draws both old and updated points #702

Closed Maahk closed 12 months ago

Maahk commented 1 year ago

Using the Python-example from OrbitPlot to update the plot after integrating works as intended.

When exchanging OrbitPlot to OrbitPlotSet and calling .update(), the updated plot shows both the old and updated points simultaneously. There was no error nor a warning that calling .update() on an OrbitPlotSet is not supported(?).

MWE:

sim = rebound.Simulation()
sim.add(m=1)
sim.add(m=0.1, e=0.041, a=0.4, inc=0.2, f=0.43, Omega=0.82, omega=2.98)
sim.add(m=1e-3, e=0.24, a=1.0, pomega=2.14)
sim.add(m=1e-3, e=0.24, a=1.5, omega=1.14, l=2.1)
sim.add(a=-2.7, e=1.4, f=-1.5,omega=-0.7) # hyperbolic orbit
ops = rebound.OrbitPlotSet(sim)

Screenshot 2023-07-07 at 09 21 39

sim.integrate(sim.t+3.2)
ops.update()
ops.fig

Screenshot 2023-07-07 at 09 21 49

rebound.moduleversion '3.25.1'

hannorein commented 1 year ago

Thanks a lot for the bug report! I can reproduce the issue (The MWE is very much appreciated!).

I don't immediately see where the problem comes from. The OrbitPlotSet.update() function just calls the update function on three OrbitPlot objects. I'll look into it...

hannorein commented 12 months ago

Sorry, that took me a bit to figure out. Turns out the issue was that when the plot was initialized, it was actually initialized twice. This fix works for me, but let me know if you encounter other problems!