ECDF Plot
Stock Returns ECDF
Dark theme ECDF showing daily stock return distribution
Output
Python
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots(figsize=(10, 6), facecolor='#0a0a0f')
ax.set_facecolor('#0a0a0f')
np.random.seed(42)
returns = np.random.normal(0.0005, 0.02, 1000) * 100 # Daily returns in %
ax.ecdf(returns, color='#4ade80', linewidth=2.5)
ax.axvline(x=0, color='#fbbf24', linestyle='-', linewidth=1.5, alpha=0.7)
var_95 = np.percentile(returns, 5)
ax.axvline(x=var_95, color='#ef4444', linestyle='--', linewidth=2, label=f'VaR 95%: {var_95:.2f}%')
ax.set_xlabel('Daily Return (%)', fontsize=12, color='white')
ax.set_ylabel('Cumulative Probability', fontsize=12, color='white')
ax.set_title('Stock Returns Distribution', fontsize=16, fontweight='bold', color='white', pad=20)
ax.tick_params(colors='white')
ax.legend(facecolor='#1a1a2f', edgecolor='#333', labelcolor='white')
ax.grid(True, alpha=0.2, color='white')
for spine in ax.spines.values():
spine.set_color('#333')
plt.tight_layout()
Library
Matplotlib
Category
Statistical
More ECDF Plot examples
☕