Line & Scatter
Benchmark Comparison
Side-by-side performance comparison with industry benchmark.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
# === STYLE CONFIG ===
COLORS = {
'company': '#3B82F6',
'benchmark': '#94A3B8',
'background': '#FFFFFF',
'text': '#1E293B',
'text_muted': '#64748B',
'grid': '#F1F5F9',
}
# === DATA ===
metrics = ['Revenue', 'Profit', 'Retention', 'NPS', 'Share']
company = [28, 18, 85, 72, 15]
benchmark = [22, 15, 78, 65, 12]
x = np.arange(len(metrics))
# === FIGURE ===
fig, ax = plt.subplots(figsize=(10, 6), dpi=100)
ax.set_facecolor(COLORS['background'])
fig.patch.set_facecolor(COLORS['background'])
# === PLOT ===
# Connect lines
for i in range(len(x)):
ax.plot([x[i], x[i]], [benchmark[i], company[i]],
color=COLORS['grid'], linewidth=2, zorder=1)
# Benchmark points
ax.scatter(x, benchmark, color=COLORS['benchmark'], s=120,
edgecolors='white', linewidths=2, label='Industry Avg', zorder=2)
# Company points
ax.scatter(x, company, color=COLORS['company'], s=120,
edgecolors='white', linewidths=2, label='Our Company', zorder=3)
# Delta annotations
for i in range(len(x)):
delta = company[i] - benchmark[i]
sign = '+' if delta > 0 else ''
color = COLORS['company'] if delta > 0 else COLORS['benchmark']
label = '{}{}'.format(sign, delta)
ax.annotate(label, xy=(x[i], company[i]),
xytext=(x[i] + 0.15, company[i]),
fontsize=9, fontweight='bold', color=color)
# === AXES ===
ax.set_xlim(-0.5, len(metrics) - 0.5)
ax.set_ylim(0, 100)
ax.set_xticks(x)
ax.set_xticklabels(metrics)
ax.set_ylabel('Score / Percentage', fontsize=10, color=COLORS['text'], labelpad=10)
# === STYLING ===
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.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 Line & Scatter examples
☕