Ridgeline Plot

Podcast Listen Duration by Genre

Audio engagement with warm sunset gradient palette

Output
Podcast Listen Duration by Genre
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats

np.random.seed(333)

genres = ['True Crime', 'Comedy', 'News', 'Tech', 'Sports', 'History']
colors = ['#F5276C', '#F54927', '#F5B027', '#F5D327', '#C82909', '#9C2007']

data = {
    'True Crime': np.random.gamma(6, 8, 500),
    'Comedy': np.random.gamma(5, 10, 500),
    'News': np.random.gamma(3, 7, 500),
    'Tech': np.random.gamma(5, 12, 500),
    'Sports': np.random.gamma(4, 15, 500),
    'History': np.random.gamma(6, 10, 500)
}

fig, ax = plt.subplots(figsize=(12, 8), facecolor='#ffffff')
ax.set_facecolor('#ffffff')

overlap = 1.6
x_range = np.linspace(0, 120, 300)

for i, (genre, minutes) in enumerate(data.items()):
    kde = stats.gaussian_kde(minutes, bw_method=0.3)
    y = kde(x_range) * 3.5
    baseline = i * overlap
    
    ax.fill_between(x_range, baseline, y + baseline, alpha=0.7, color=colors[i])
    ax.plot(x_range, y + baseline, color=colors[i], linewidth=2.5)
    
    ax.text(-3, baseline + 0.12, genre, fontsize=11, color='#1f2937',
            ha='right', va='bottom', fontweight='600')

ax.set_xlim(-25, 120)
ax.set_ylim(-0.3, len(genres) * overlap + 1.8)
ax.set_xlabel('Listen Duration (minutes)', fontsize=12, color='#374151', fontweight='500')
ax.set_title('Podcast Listen Duration by Genre', fontsize=16, color='#1f2937', fontweight='bold', pad=20)

ax.tick_params(axis='x', colors='#374151', labelsize=10)
ax.tick_params(axis='y', left=False, labelleft=False)
ax.spines['bottom'].set_color('#e5e7eb')
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_visible(False)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support