Scatter Plot
Before After Scatter
Paired scatter showing transitions with arrows.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
# === STYLE CONFIG ===
COLORS = {
'before': '#94A3B8',
'after': '#10B981',
'arrow': '#64748B',
'background': '#FFFFFF',
'text': '#1E293B',
'text_muted': '#64748B',
'grid': '#F1F5F9',
}
# === DATA ===
np.random.seed(42)
n = 15
x_before = np.random.uniform(20, 60, n)
y_before = np.random.uniform(20, 50, n)
x_after = x_before + np.random.uniform(5, 25, n)
y_after = y_before + np.random.uniform(10, 30, n)
# === FIGURE ===
fig, ax = plt.subplots(figsize=(10, 6), dpi=100)
ax.set_facecolor(COLORS['background'])
fig.patch.set_facecolor(COLORS['background'])
# === PLOT ===
for xb, yb, xa, ya in zip(x_before, y_before, x_after, y_after):
ax.annotate('', xy=(xa, ya), xytext=(xb, yb),
arrowprops=dict(arrowstyle='->', color=COLORS['arrow'], lw=1, alpha=0.4))
ax.scatter(x_before, y_before, s=150, c=COLORS['before'], alpha=0.2, zorder=2)
ax.scatter(x_before, y_before, s=60, c=COLORS['before'], alpha=0.8,
edgecolors='white', linewidths=1.5, label='Before', zorder=3)
ax.scatter(x_after, y_after, s=180, c=COLORS['after'], alpha=0.2, zorder=4)
ax.scatter(x_after, y_after, s=70, c=COLORS['after'], alpha=0.9,
edgecolors='white', linewidths=1.5, label='After', zorder=5)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_color(COLORS['grid'])
ax.spines['bottom'].set_color(COLORS['grid'])
ax.yaxis.grid(True, color=COLORS['grid'], linewidth=1)
ax.set_axisbelow(True)
ax.tick_params(axis='both', colors=COLORS['text_muted'], labelsize=9, length=0, pad=8)
ax.set_xlabel('Efficiency', fontsize=10, color=COLORS['text'], labelpad=10)
ax.set_ylabel('Performance', fontsize=10, color=COLORS['text'], labelpad=10)
ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.12),
ncol=2, frameon=False, fontsize=9, labelcolor=COLORS['text_muted'])
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Pairwise Data
More Scatter Plot examples
☕