You are reading an old version of the documentation (v1.5.0). For the latest version see

We're updating the default styles for Matplotlib 2.0

Learn what to expect in the new updates


Previous topic

mplot3d example code:

Next topic

mplot3d example code:

This Page

mplot3d example code: bars3d_demo.pyΒΆ

(Source code, png, hires.png, pdf)

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
for c, z in zip(['r', 'g', 'b', 'y'], [30, 20, 10, 0]):
    xs = np.arange(20)
    ys = np.random.rand(20)

    # You can provide either a single color or an array. To demonstrate this,
    # the first bar of each set will be colored cyan.
    cs = [c] * len(xs)
    cs[0] = 'c', ys, zs=z, zdir='y', color=cs, alpha=0.8)


Keywords: python, matplotlib, pylab, example, codex (see Search examples)