I want to animate an 3D object (poly3Dcollection). The object consist of 32 (triangular) patches. Over time the coordinates of the object change. For this example the z-values of the coordinates for the patches increases 0.1 per frame in the animation, making the object move upwards. The problem: the animation is really slow. Are there ways to increase the speed of an animation for this example?
I already checked where the animation speed decreases. It's not inside the function, because a and b are printed immediately after each other (see code). I think the problem is in updating the figure with a new frame. leg1p is a list with 1000 elements. Each elements consist of 32 lists (the patches) with each 3 coordinates (x,y,z), which form a patch.
def animate(i):
print('a')
plt.gcf()
ax = p3A.Axes3D(fig)
ax.set_aspect('equal')
ax.set_xlim3d([-10, 140])
ax.set_xlabel('X')
ax.set_ylim3d([-75, 75])
ax.set_ylabel('Y')
ax.set_zlim3d([-75, 75])
ax.set_zlabel('Z')
ax.elev = 30
ax.azim = -230
ax.dist = 8
ax.add_collection3d(a3.art3d.Poly3DCollection(leg1p[i]))
print('b')
anim = animation.FuncAnimation(fig, animate, frames=1000, interval=40, repeat=False)
plt.show()
In the end I would like to have faster animation, because I need to add even more objects. I am also trying to safe the animation, but this takes even more (to much) time.