Area Chart

Cohen's d Effect Sizes

Effect size estimates with confidence intervals - R style

Output
Cohen's d Effect Sizes
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(42)

# Effect sizes for different comparisons
comparisons = ['A vs B', 'A vs C', 'B vs C', 'A vs D', 'B vs D']
d_values = [0.45, 0.82, 0.35, -0.28, 0.65]
ci_low = [d - np.random.uniform(0.2, 0.35) for d in d_values]
ci_high = [d + np.random.uniform(0.2, 0.35) for d in d_values]
y = np.arange(len(comparisons))

fig, ax = plt.subplots(figsize=(10, 6), facecolor='#ffffff')
ax.set_facecolor('#ffffff')

# Effect size guidelines
ax.axvspan(-0.2, 0.2, alpha=0.1, color='#6b7280', label='Negligible')
ax.axvspan(0.2, 0.5, alpha=0.1, color='#6CF527')
ax.axvspan(0.5, 0.8, alpha=0.1, color='#F5B027')
ax.axvspan(0.8, 1.5, alpha=0.1, color='#F5276C')
ax.axvline(0, color='#1f2937', linewidth=1.5)

# CI bars and points
for i, (d, lo, hi) in enumerate(zip(d_values, ci_low, ci_high)):
    color = '#4927F5' if d > 0 else '#F5276C'
    ax.fill_betweenx([i-0.15, i+0.15], lo, hi, alpha=0.3, color=color)
    ax.plot([lo, hi], [i, i], color=color, linewidth=2)
    ax.scatter([d], [i], color=color, s=100, zorder=5, edgecolors='white', linewidth=2)

ax.set_yticks(y)
ax.set_yticklabels(comparisons)
ax.set_xlabel("Cohen's d", color='#1f2937', fontsize=11, fontweight='500')
ax.set_title('Effect Size Estimates with 95% CI', color='#1f2937', fontsize=13, fontweight='600', pad=15)
ax.tick_params(colors='#374151', labelsize=10)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_color('#e5e7eb')
ax.spines['bottom'].set_color('#e5e7eb')
ax.xaxis.grid(True, color='#f3f4f6', linewidth=0.8)
ax.set_xlim(-1, 1.5)

# Size labels
ax.text(0.35, -0.7, 'Small', fontsize=8, color='#6CF527', ha='center')
ax.text(0.65, -0.7, 'Medium', fontsize=8, color='#F5B027', ha='center')
ax.text(1.1, -0.7, 'Large', fontsize=8, color='#F5276C', ha='center')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Basic Charts

Did this help you?

Support PyLucid to keep it free & growing

Support