Stream Graph

Social Media Platform Engagement Stream

Stream visualization showing user engagement across major social media platforms over time.

Output
Social Media Platform Engagement Stream
Python
import matplotlib.pyplot as plt
import numpy as np

COLORS = {
    'layers': ['#1DA1F2', '#E4405F', '#0077B5', '#FF0000', '#25D366', '#000000'],
    'background': '#0a0a0f',
    'text': '#ffffff',
    'grid': '#333333',
}

np.random.seed(789)
weeks = np.arange(0, 52)

# Platform engagement
twitter = 30 + 10 * np.sin(weeks * np.pi / 13) + np.random.normal(0, 3, 52)
instagram = 45 + 0.3 * weeks + 8 * np.cos(weeks * np.pi / 10) + np.random.normal(0, 3, 52)
linkedin = 20 + 0.2 * weeks + 5 * np.sin(weeks * np.pi / 26) + np.random.normal(0, 2, 52)
youtube = 50 + 0.4 * weeks + 10 * np.sin(weeks * np.pi / 8) + np.random.normal(0, 4, 52)
whatsapp = 35 + 5 * np.cos(weeks * np.pi / 12) + np.random.normal(0, 2, 52)
tiktok = 10 + 0.8 * weeks + np.random.exponential(3, 52)

data = [np.clip(d, 1, None) for d in [twitter, instagram, linkedin, youtube, whatsapp, tiktok]]

fig, ax = plt.subplots(figsize=(14, 6), facecolor=COLORS['background'])
ax.set_facecolor(COLORS['background'])

# Custom colors for each platform
platform_colors = ['#1DA1F2', '#E4405F', '#0077B5', '#FF0000', '#25D366', '#FE2C55']

ax.stackplot(weeks, *data, colors=platform_colors, alpha=0.85, baseline='sym',
             labels=['Twitter/X', 'Instagram', 'LinkedIn', 'YouTube', 'WhatsApp', 'TikTok'])

ax.axhline(0, color=COLORS['grid'], linewidth=0.5, alpha=0.5)
ax.set_xlim(0, 51)

ax.set_title('Social Media Engagement (Weekly)', color=COLORS['text'], fontsize=14, fontweight='bold', pad=15)
ax.set_xlabel('Week', color=COLORS['text'], fontsize=11)
ax.set_ylabel('Engagement Score', color=COLORS['text'], fontsize=11)

ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.12), frameon=False, labelcolor=COLORS['text'], fontsize=9, ncol=5)

for spine in ax.spines.values():
    spine.set_visible(False)
ax.tick_params(colors=COLORS['text'], labelsize=9)

plt.tight_layout()
plt.subplots_adjust(bottom=0.18)
plt.show()
Library

Matplotlib

Category

Time Series

Did this help you?

Support PyLucid to keep it free & growing

Support