Error Bar Chart

A/B Test Results Comparison

Website A/B testing results comparing control and variant performance with confidence intervals.

Output
A/B Test Results Comparison
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(42)

# A/B test data
metrics = ['Conversion\nRate (%)', 'Avg Session\nDuration (min)', 'Bounce\nRate (%)', 'Pages per\nSession', 'Revenue\nper User ($)']
control = np.array([3.2, 4.5, 45, 3.8, 12.50])
variant = np.array([4.1, 5.2, 38, 4.5, 15.80])
control_ci = np.array([0.3, 0.4, 3, 0.3, 1.20])
variant_ci = np.array([0.35, 0.45, 2.8, 0.35, 1.50])

# Normalize for display
control_norm = control / control * 100
variant_norm = variant / control * 100

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

x = np.arange(len(metrics))

ax.errorbar(x - 0.12, [100]*5, yerr=control_ci/control*100, fmt='s', 
            color='#F5276C', ecolor='#F5276C', elinewidth=2, capsize=5,
            capthick=2, markersize=12, markeredgecolor='white',
            markeredgewidth=1.5, label='Control (baseline)', alpha=0.9)

ax.errorbar(x + 0.12, variant_norm, yerr=variant_ci/control*100, fmt='o',
            color='#6CF527', ecolor='#6CF527', elinewidth=2, capsize=5,
            capthick=2, markersize=12, markeredgecolor='white',
            markeredgewidth=1.5, label='Variant B', alpha=0.9)

# Highlight improvements
for i, (v, c) in enumerate(zip(variant_norm, [100]*5)):
    if v > c:
        ax.annotate(f'+{v-c:.0f}%', xy=(i + 0.12, v + 5), ha='center',
                   color='#6CF527', fontsize=9, fontweight='bold')

ax.axhline(y=100, color='#666', linestyle='--', linewidth=1, alpha=0.5)
ax.set_xlabel('Metric', fontsize=11, color='white', fontweight='500')
ax.set_ylabel('Relative Performance (%)', fontsize=11, color='white', fontweight='500')
ax.set_title('A/B Test Results: Variant B vs Control', fontsize=14, 
             color='white', fontweight='bold', pad=15)

ax.set_xticks(x)
ax.set_xticklabels(metrics)
ax.legend(facecolor='#1a1a2e', edgecolor='#333', labelcolor='white', fontsize=10)
ax.tick_params(colors='#94a3b8', labelsize=9)
ax.set_ylim(75, 140)
ax.grid(True, axis='y', alpha=0.2, color='#4a4a6a')
for spine in ax.spines.values():
    spine.set_color('#333333')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support