Stream Graph

Music Genre Popularity Stream

Stream graph showing the evolution of music genre popularity over decades with neon color palette.

Output
Music Genre Popularity Stream
Python
import matplotlib.pyplot as plt
import numpy as np

COLORS = {
    'layers': ['#F5276C', '#F54927', '#F5B027', '#27D3F5', '#6CF527', '#4927F5'],
    'background': '#0a0a0f',
    'text': '#ffffff',
    'grid': '#333333',
}

np.random.seed(42)
years = np.arange(1970, 2025)
n_years = len(years)

# Genre popularity over time
rock = 40 * np.exp(-((years - 1985)**2) / 500) + 10
pop = 30 + 15 * np.sin((years - 1980) * np.pi / 20) + np.random.normal(0, 3, n_years)
hiphop = 50 / (1 + np.exp(-(years - 1995) / 5)) + np.random.normal(0, 2, n_years)
electronic = 40 / (1 + np.exp(-(years - 2005) / 4)) + np.random.normal(0, 2, n_years)
rb = 20 + 10 * np.sin((years - 1990) * np.pi / 15) + np.random.normal(0, 2, n_years)
country = 15 + 5 * np.sin((years - 1985) * np.pi / 25) + np.random.normal(0, 2, n_years)

data = [rock, pop, hiphop, electronic, rb, country]

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

ax.stackplot(years, *data, colors=COLORS['layers'], alpha=0.85, baseline='sym',
             labels=['Rock', 'Pop', 'Hip-Hop', 'Electronic', 'R&B', 'Country'])

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

ax.set_title('Music Genre Popularity (1970-2024)', color=COLORS['text'], fontsize=14, fontweight='bold', pad=15)
ax.set_xlabel('Year', color=COLORS['text'], fontsize=11)
ax.set_ylabel('Popularity Index', 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