Stream Graph

Smart Home Device Usage Stream

Stream visualization of smart home device activity throughout the day.

Output
Smart Home Device Usage Stream
Python
import matplotlib.pyplot as plt
import numpy as np

COLORS = {
    'background': '#0a0a0f',
    'text': '#ffffff',
    'grid': '#333333',
}

np.random.seed(3131)
hours = np.arange(0, 24)

speakers = 15 + 20 * np.exp(-((hours - 8)**2) / 8) + 15 * np.exp(-((hours - 19)**2) / 10) + np.random.normal(0, 2, 24)
lighting = 10 + 25 * np.exp(-((hours - 20)**2) / 15) + 8 * np.exp(-((hours - 7)**2) / 5) + np.random.normal(0, 2, 24)
thermostat = 20 + 10 * np.cos(hours * np.pi / 12) + np.random.normal(0, 1, 24)
security = 30 + 5 * np.sin(hours * np.pi / 12) + np.random.normal(0, 1, 24)
appliances = 10 + 15 * np.exp(-((hours - 12)**2) / 10) + 12 * np.exp(-((hours - 19)**2) / 8) + np.random.normal(0, 2, 24)

data = [np.clip(d, 1, None) for d in [speakers, lighting, thermostat, security, appliances]]
colors = ['#27D3F5', '#F5B027', '#6CF527', '#F5276C', '#4927F5']

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

ax.stackplot(hours, *data, colors=colors, alpha=0.85, baseline='sym',
             labels=['Smart Speakers', 'Lighting', 'Thermostat', 'Security', 'Appliances'])

ax.axhline(0, color=COLORS['grid'], linewidth=0.5, alpha=0.5)
ax.set_xlim(0, 23)
ax.set_xticks([0, 6, 12, 18, 24])
ax.set_xticklabels(['12 AM', '6 AM', '12 PM', '6 PM', '12 AM'])

ax.set_title('Smart Home Device Activity', color=COLORS['text'], fontsize=14, fontweight='bold', pad=15)
ax.set_xlabel('Hour', color=COLORS['text'], fontsize=11)
ax.set_ylabel('Interactions', 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