Scatter Plot

Connected Timeline

Time series comparison showing digital vs traditional market share evolution.

Output
Connected Timeline
Python
import matplotlib.pyplot as plt
import numpy as np

# === STYLE CONFIG ===
COLORS = {
    'primary': '#6366F1',
    'secondary': '#EC4899',
    'background': '#FFFFFF',
    'text': '#1E293B',
    'text_muted': '#64748B',
    'grid': '#F1F5F9',
}

# === DATA ===
years = np.arange(2015, 2025)
metric_a = [20, 25, 28, 35, 42, 48, 55, 62, 70, 78]
metric_b = [80, 75, 70, 62, 55, 50, 45, 38, 32, 28]

# === FIGURE ===
fig, ax = plt.subplots(figsize=(10, 6), dpi=100)
ax.set_facecolor(COLORS['background'])
fig.patch.set_facecolor(COLORS['background'])

# === PLOT ===
# Lines with glow
for metrics, color, label in [(metric_a, COLORS['primary'], 'Digital'),
                               (metric_b, COLORS['secondary'], 'Traditional')]:
    # Glow line
    ax.plot(years, metrics, color=color, linewidth=8, alpha=0.15, zorder=1)
    # Main line
    ax.plot(years, metrics, color=color, linewidth=2.5, zorder=2)
    # Points with glow
    ax.scatter(years, metrics, s=150, c=color, alpha=0.2, zorder=3)
    ax.scatter(years, metrics, s=60, c=color, 
               edgecolors='white', linewidths=2, label=label, zorder=4)

# Start/End annotations
for y, m, label in [(2015, metric_a[0], f'{metric_a[0]}%'), 
                     (2024, metric_a[-1], f'{metric_a[-1]}%')]:
    ax.annotate(label, (y, m), xytext=(0, 12), textcoords='offset points',
                ha='center', fontsize=9, color=COLORS['primary'], fontweight='bold')

# === 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.set_xlim(2014, 2025)
ax.set_ylim(0, 100)
ax.set_xlabel('Year', fontsize=10, color=COLORS['text'], labelpad=10)
ax.set_ylabel('Market Share (%)', 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

Did this help you?

Support PyLucid to keep it free & growing

Support