How can I create stacked line graph?

Newer versions of matplotlib contain the function plt.stackplot, which allow for several different “out-of-the-box” stacked area plots:

import numpy as np
import pylab as plt

X = np.arange(0, 10, 1) 
Y = X + 5 * np.random.random((5, X.size))

baseline = ["zero", "sym", "wiggle", "weighted_wiggle"]
for n, v in enumerate(baseline):
    plt.subplot(2 ,2, n + 1)
    plt.stackplot(X, *Y, baseline=v)
    plt.title(v)
    plt.axis('tight')
plt.show()

Stack Plot using plt.stackplot.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)