from numpy import arange, ones
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

o = ones(4)
r = arange(4)

# clear annotation
ax.grid(False)

for a in (ax.w_xaxis, ax.w_yaxis, ax.w_zaxis):
    for t in a.get_ticklines()+a.get_ticklabels():
        t.set_visible(False)
    a.line.set_visible(False)
    a.pane.set_visible(False)

# draw planes
for z in arange(3)+1:
    for zd in ['x', 'y', 'z']:
        ax.bar(r, o*4, zs=z, zdir=zd, alpha=.05, width=1)

# draw N
for i in [1, 2]:
    ax.bar3d([3-i], [0], [i], [.9], [.1], [.9], color='y', linewidth=.1)
    ax.bar3d(o+(i*(-1)**i), o-1, r, o-.1, o-.9, o-.1, color='y', linewidth=.1)

# draw cage
ax.bar3d([0], [0], [0], [4], [4], [4], alpha=.05, color='w', linewidth=0)

# animation
ax.view_init(90,-90)
plt.ion()
plt.draw()
plt.show()

for l in arange(25):
    ax.set_xlim3d(1.5-.1*l,2.5+.1*l)
    ax.set_ylim3d(1.5-.1*l,2.5+.1*l)
    ax.view_init(90-3*l, -90+l)
    plt.draw()

plt.title("NumPy")
plt.ioff()
plt.show()