.. _mplot3d-bars3d_demo:

mplot3d example code: bars3d_demo.py
====================================



.. plot:: /tmp/buildd/matplotlib-0.99.3/doc/mpl_examples/mplot3d/bars3d_demo.py

::

    from mpl_toolkits.mplot3d import Axes3D
    import matplotlib.pyplot as plt
    import numpy as np
    
    fig = plt.figure()
    ax = Axes3D(fig)
    for c, z in zip(['r', 'g', 'b', 'y'], [30, 20, 10, 0]):
        xs = np.arange(20)
        ys = np.random.rand(20)
        ax.bar(xs, ys, zs=z, zdir='y', color=c, alpha=0.8)
    
    ax.set_xlabel('X')
    ax.set_ylabel('Y')
    ax.set_zlabel('Z')
    
    plt.show()
    
    

Keywords: python, matplotlib, pylab, example, codex (see :ref:`how-to-search-examples`)