You are reading an old version of the documentation (v2.0.0). For the latest version see https://matplotlib.org/stable/
matplotlib

Travis-CI:

This Page

pylab_examples example code: stackplot_demo.pyΒΆ

(Source code, png, pdf)

../../_images/stackplot_demo_00_00.png

(png, pdf)

../../_images/stackplot_demo_01_00.png
import numpy as np
import matplotlib.pyplot as plt


def fnx():
    return 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)
plt.show()

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

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