Hi,
Animations of 3d scenes is a bit tricky, because set_data() functions
for wireframe and surface plots are not available. However, you can
still do it by creating new surfaces or wireframes every frame, and
removing the old one. I've attached an example that does this and will
be added to svn soon.
You could also rotate the 3d axes:
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as np
plt.ion()
fig = plt.figure()
ax = axes3d.Axes3D(fig)
X, Y, Z = axes3d.get_test_data(0.1)
ax.plot_wireframe(X, Y, Z, rstride=5, cstride=5)
for angle in range(0, 360):
ax.view_init(30, angle)
plt.draw()
Regards,
Reinier
2009/11/25 Sébastien Barthélemy <[email protected]>:
> Hello,
>
> I would like to do animations of a 3d scene. Thus I would need do to
> animation of some mplot3d-generated plot. Has somebody already tried it ? Is
> it possible at all ? My first test don't work, but I never did an animation
> in matplotlib before. I would like to be sure this is not a dead end befor
> digging deeper.
>
> Thank you !
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
--
Reinier Heeres
Tel: +31 6 10852639
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as np
import time
def generate(X, Y, phi):
R = 1 - np.sqrt(X**2 + Y**2)
return np.cos(2 * np.pi * X + phi) * R
plt.ion()
fig = plt.figure()
ax = axes3d.Axes3D(fig)
xs = np.linspace(-1, 1, 50)
ys = np.linspace(-1, 1, 50)
X, Y = np.meshgrid(xs, ys)
Z = generate(X, Y, 0.0)
wframe = None
tstart = time.time()
for phi in np.linspace(0, 360 / 2 / np.pi, 100):
oldcol = wframe
Z = generate(X, Y, phi)
wframe = ax.plot_wireframe(X, Y, Z, rstride=2, cstride=2)
# Remove old line collection before drawing
if oldcol is not None:
ax.collections.remove(oldcol)
plt.draw()
print 'FPS: %f' % (100 / (time.time() - tstart))
------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users