Line & Scatter
Growth Trajectory
Projected growth path with historical data and forecast.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
# === STYLE CONFIG ===
COLORS = {
'historical': '#1E293B',
'forecast': '#3B82F6',
'confidence': '#3B82F6',
'background': '#FFFFFF',
'text': '#1E293B',
'text_muted': '#64748B',
'grid': '#F1F5F9',
}
# === DATA ===
# Historical
hist_x = np.arange(2019, 2024)
hist_y = [12, 18, 24, 35, 52]
# Forecast
fore_x = np.arange(2023, 2027)
fore_y = [52, 72, 95, 125]
fore_upper = [52, 82, 115, 160]
fore_lower = [52, 62, 75, 90]
# === FIGURE ===
fig, ax = plt.subplots(figsize=(10, 6), dpi=100)
ax.set_facecolor(COLORS['background'])
fig.patch.set_facecolor(COLORS['background'])
# === PLOT ===
# Confidence band
ax.fill_between(fore_x, fore_lower, fore_upper,
color=COLORS['confidence'], alpha=0.15)
# Historical line
ax.plot(hist_x, hist_y, color=COLORS['historical'], linewidth=2.5,
marker='o', markersize=8, markerfacecolor='white',
markeredgewidth=2, label='Historical', zorder=3)
# Forecast line
ax.plot(fore_x, fore_y, color=COLORS['forecast'], linewidth=2.5,
linestyle='--', marker='s', markersize=8, markerfacecolor='white',
markeredgewidth=2, label='Forecast', zorder=3)
# Value labels
for x, y in zip(hist_x, hist_y):
ax.annotate(f'${y}M', xy=(x, y), xytext=(0, 10),
textcoords='offset points', ha='center',
fontsize=9, color=COLORS['text'])
for x, y in zip(fore_x[1:], fore_y[1:]):
ax.annotate(f'${y}M', xy=(x, y), xytext=(0, 10),
textcoords='offset points', ha='center',
fontsize=9, color=COLORS['forecast'])
# === AXES ===
ax.set_xlim(2018.5, 2026.5)
ax.set_ylim(0, 180)
ax.set_xlabel('Year', fontsize=10, color=COLORS['text'], labelpad=10)
ax.set_ylabel('Revenue ($ Million)', 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
☕