I am trying to animate a 3D bar graph with blit=True. I am able to do animation with blit=False but it takes longer (30 msec for a graph of 60 bars) hence I am trying with blit=True. But the animation doesn't happen, no error as well.
I couldn't find any documentation of animating 3D bar graph though there are details available about animation of 3D line graphs.
My minimal code is given below.
#!/usr/bin/env python3
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
import random
fig = plt.figure(figsize=(5, 5))
plt.subplots_adjust(top=0.99, bottom=0.01, left=0.01, right=0.99)
ax1 = fig.add_subplot(111, projection='3d')
x = 0
y = 0
z = random.randint(0, 10)
main = ax1.bar3d(1, 1, 0, 1, 1, z, alpha=1, shade=True)
def init():
return main,
def animate(i):
z = random.randint(0, 10)
print ("z is ", z)
return main,
ani = FuncAnimation(fig, animate, interval=500, blit=True, init_func=init, frames=200)
plt.show()
What I am expecting with this code is a height changing bar at every 500 msec.