Stream Graph
E-commerce Category Sales Stream
Stream graph showing seasonal e-commerce sales patterns across product categories.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
COLORS = {
'layers': ['#EC4899', '#8B5CF6', '#06B6D4', '#10B981', '#F59E0B'],
'background': '#ffffff',
'text': '#1f2937',
'grid': '#e5e7eb',
}
np.random.seed(303)
weeks = np.arange(0, 52)
# Sales categories with seasonal patterns
fashion = 30 + 15 * np.sin(weeks * np.pi / 13) + 20 * (weeks > 45) + np.random.normal(0, 3, 52)
electronics = 25 + 10 * np.cos(weeks * np.pi / 10) + 30 * (weeks > 47) + np.random.normal(0, 3, 52)
home = 20 + 8 * np.sin(weeks * np.pi / 26) + np.random.normal(0, 2, 52)
beauty = 15 + 5 * np.sin(weeks * np.pi / 8) + np.random.normal(0, 2, 52)
food = 25 + 10 * ((weeks > 20) & (weeks < 35)) + np.random.normal(0, 2, 52)
data = [np.clip(d, 1, None) for d in [fashion, electronics, home, beauty, food]]
fig, ax = plt.subplots(figsize=(14, 6), facecolor=COLORS['background'])
ax.set_facecolor(COLORS['background'])
ax.stackplot(weeks, *data, colors=COLORS['layers'], alpha=0.85, baseline='sym',
labels=['Fashion', 'Electronics', 'Home & Garden', 'Beauty', 'Food & Grocery'])
ax.axhline(0, color=COLORS['grid'], linewidth=0.5)
ax.set_xlim(0, 51)
ax.set_title('E-commerce Sales by Category (Weekly)', color=COLORS['text'], fontsize=14, fontweight='bold', pad=15)
ax.set_xlabel('Week', color=COLORS['text'], fontsize=11)
ax.set_ylabel('Sales (millions)', color=COLORS['text'], fontsize=11)
ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.12), frameon=False, fontsize=9, ncol=5)
for spine in ax.spines.values():
spine.set_color(COLORS['grid'])
ax.tick_params(colors=COLORS['text'], labelsize=9)
plt.tight_layout()
plt.subplots_adjust(bottom=0.18)
plt.show()
Library
Matplotlib
Category
Time Series
More Stream Graph examples
☕