You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
matplotlib glitch when rotating interactively a 3d animation #16069
matplotlib glitch when rotating interactively a 3d animation
Plotting a 3d animation, matplotlib glitches when rotating interactively, despite doing it well when zooming. Setting a callback to stop animation during rotation doesn't seem to help, since (see code and attached video) the little red ball, which should be following the blue line, goes "off-track"
Using matplotlib 3.1.2
importnumpyasnpimportmatplotlib.pyplotaspltfrommpl_toolkits.mplot3dimportAxes3Dfrommatplotlib.animationimportFuncAnimationt=np.linspace(0, 20*np.pi, 1000)
x=ty=np.cos(t)
z=np.sin(t)
defanimate(i, *fargs):
x, y, z=fargs[0:3]
ln=fargs[3]
# Plot small ball at time t[i]ln.set_data_3d([x[i]], [y[i]], [z[i]])
ln.set_color('r')
ln.set_marker('.')
ln.set_markersize(10)
returnln,
fig=plt.figure(figsize=(9,7))
ax=plt.axes(projection='3d')
fix_ln=ax.plot(x, y, z, 'b-')[0]
ln=ax.plot([], [], [])[0]
ani=FuncAnimation(fig, animate, frames=np.arange(t.size), repeat=False, fargs=(x, y, z, ln), interval=0, blit=True)
# Comment the two following lines to play animation without callbacks:plt.connect('button_press_event', lambdaevent: ani.event_source.stop())
plt.connect('button_release_event', lambdaevent: ani.event_source.start())
plt.show()
Matplotlib version
Operating system: Ubuntu 19.10 eoan, Linux 5.3.0-24-generic #26-Ubuntu SMP Thu Nov 14 01:33:18 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Activity