You are reading an old version of the documentation (v1.4.3). 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

pylab_examples example code:

Next topic

pylab_examples example code:

This Page

pylab_examples example code: stackplot_demo.pyΒΆ

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


(png, hires.png, pdf)

import numpy as np
from matplotlib import pyplot as plt

fnx = lambda : np.random.randint(5, 50, 10)
y = np.row_stack((fnx(), fnx(), fnx()))
x = np.arange(10)

y1, y2, y3 = fnx(), fnx(), fnx()

fig, ax = plt.subplots()
ax.stackplot(x, y)

fig, ax = plt.subplots()
ax.stackplot(x, y1, y2, y3)

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