Ridgeline Plot

Cryptocurrency Daily Returns

Volatile crypto distributions with neon trading aesthetic

Output
Cryptocurrency Daily Returns
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats

np.random.seed(1212)

coins = ['Bitcoin', 'Ethereum', 'Solana', 'Cardano', 'Polygon', 'Avalanche']
colors = ['#F5B027', '#276CF5', '#9C2007', '#27D3F5', '#4927F5', '#F5276C']

data = {
    'Bitcoin': np.random.normal(0, 3, 600),
    'Ethereum': np.random.normal(0, 4, 600),
    'Solana': np.random.normal(0, 7, 600),
    'Cardano': np.random.normal(0, 6, 600),
    'Polygon': np.random.normal(0, 5.5, 600),
    'Avalanche': np.random.normal(0, 6.5, 600)
}

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

overlap = 1.7
x_range = np.linspace(-25, 25, 300)

for i, (coin, returns) in enumerate(data.items()):
    kde = stats.gaussian_kde(returns, bw_method=0.25)
    y = kde(x_range) * 4
    baseline = i * overlap
    
    for w, a in [(14, 0.08), (10, 0.12), (6, 0.22), (3, 0.45)]:
        ax.plot(x_range, y + baseline, color=colors[i], linewidth=w, alpha=a)
    
    ax.fill_between(x_range, baseline, y + baseline, alpha=0.45, color=colors[i])
    ax.plot(x_range, y + baseline, color='white', linewidth=1.2, alpha=0.9)
    
    ax.text(-27, baseline + 0.15, coin, fontsize=10, color=colors[i],
            ha='right', va='bottom', fontweight='600')

ax.axvline(x=0, color='#333333', linewidth=1, linestyle='--', alpha=0.5)
ax.set_xlim(-35, 25)
ax.set_ylim(-0.3, len(coins) * overlap + 2)
ax.set_xlabel('Daily Return (%)', fontsize=12, color='#555555', fontweight='500')
ax.set_title('Cryptocurrency Daily Returns', fontsize=16, color='white', fontweight='bold', pad=20)

ax.tick_params(axis='x', colors='#444444', labelsize=10)
ax.tick_params(axis='y', left=False, labelleft=False)
for spine in ax.spines.values():
    spine.set_visible(False)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support