Stream Graph

Stream Graph

Symmetric streamgraph with flowing layers.

Output
Stream Graph
Python
import matplotlib.pyplot as plt
import numpy as np

COLORS = {
    'layers': ['#6366F1', '#8B5CF6', '#A855F7', '#C084FC', '#D8B4FE'],
    'background': '#FFFFFF',
    'text': '#1E293B',
    'text_muted': '#64748B',
}

np.random.seed(42)
x = np.linspace(0, 10, 50)
y = [np.sin(x + i) + np.random.uniform(0.5, 1.5, len(x)) for i in range(5)]

fig, ax = plt.subplots(figsize=(12, 5), dpi=100)
ax.set_facecolor(COLORS['background'])
fig.patch.set_facecolor(COLORS['background'])

ax.stackplot(x, *y, colors=COLORS['layers'], alpha=0.85, baseline='sym')

ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_visible(False)
ax.spines['bottom'].set_visible(False)

ax.axhline(0, color=COLORS['text_muted'], linewidth=0.5, alpha=0.5)
ax.tick_params(axis='both', colors=COLORS['text_muted'], labelsize=9, length=0, pad=8)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Time Series

Did this help you?

Support PyLucid to keep it free & growing

Support