Ridgeline Plot
Stock Price Volatility by Sector
Daily returns with financial neon theme and glow effects
Output
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats
np.random.seed(111)
sectors = ['Tech', 'Finance', 'Healthcare', 'Energy', 'Consumer', 'Industrial']
colors = ['#27D3F5', '#6CF527', '#F5276C', '#F5B027', '#4927F5', '#F54927']
data = {
'Tech': np.random.normal(0, 2.5, 600),
'Finance': np.random.normal(0, 1.8, 600),
'Healthcare': np.random.normal(0, 1.5, 600),
'Energy': np.random.normal(0, 3.0, 600),
'Consumer': np.random.normal(0, 1.2, 600),
'Industrial': np.random.normal(0, 1.6, 600)
}
fig, ax = plt.subplots(figsize=(12, 8), facecolor='#0a0a0f')
ax.set_facecolor('#0a0a0f')
overlap = 1.7
x_range = np.linspace(-10, 10, 300)
for i, (sector, returns) in enumerate(data.items()):
kde = stats.gaussian_kde(returns, bw_method=0.25)
y = kde(x_range) * 4
baseline = i * overlap
# Intense glow
for w, a in [(14, 0.08), (10, 0.12), (6, 0.2), (3, 0.4)]:
ax.plot(x_range, y + baseline, color=colors[i], linewidth=w, alpha=a)
ax.fill_between(x_range, baseline, y + baseline, alpha=0.5, color=colors[i])
ax.plot(x_range, y + baseline, color='white', linewidth=1.2, alpha=0.9)
ax.text(-11.5, baseline + 0.15, sector, fontsize=11, color=colors[i],
ha='right', va='bottom', fontweight='600')
ax.axvline(x=0, color='#333333', linewidth=1, linestyle='--', alpha=0.5)
ax.set_xlim(-14, 10)
ax.set_ylim(-0.3, len(sectors) * overlap + 2)
ax.set_xlabel('Daily Return (%)', fontsize=12, color='#666666', fontweight='500')
ax.set_title('Stock Price Volatility by Sector', fontsize=16, color='white', fontweight='bold', pad=20)
ax.tick_params(axis='x', colors='#555555', 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
More Ridgeline Plot examples
☕