Scatter Plot
Gradient Spiral Trail
Animated-look spiral with gradient color line, progressive sizing, and annotated waypoints.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.collections import LineCollection
# === STYLE CONFIG ===
COLORS = {
'primary': '#6366F1',
'start': '#10B981',
'end': '#EF4444',
'background': '#FFFFFF',
'text': '#1E293B',
'text_muted': '#64748B',
'grid': '#F1F5F9',
}
# === DATA ===
np.random.seed(42)
n_points = 100
t = np.linspace(0, 5*np.pi, n_points)
x = t * np.cos(t) / 4 + 5
y = t * np.sin(t) / 4 + 5
# === FIGURE ===
fig, ax = plt.subplots(figsize=(10, 10), dpi=100)
ax.set_facecolor(COLORS['background'])
fig.patch.set_facecolor(COLORS['background'])
# === PLOT ===
# Create gradient line using LineCollection
points = np.array([x, y]).T.reshape(-1, 1, 2)
segments = np.concatenate([points[:-1], points[1:]], axis=1)
# Color gradient along the path
colors = plt.cm.cool(np.linspace(0, 1, len(segments)))
# Multiple glow layers for the line
for width, alpha in [(12, 0.05), (8, 0.1), (5, 0.2)]:
lc = LineCollection(segments, colors=colors, linewidth=width, alpha=alpha)
ax.add_collection(lc)
# Main gradient line
lc_main = LineCollection(segments, colors=colors, linewidth=2.5)
ax.add_collection(lc_main)
# Scatter points with progressive sizing and glow
sizes = np.linspace(20, 120, n_points)
alphas = np.linspace(0.2, 0.9, n_points)
# Glow layer
for i in range(n_points):
ax.scatter(x[i], y[i], s=sizes[i]*2, c=[colors[min(i, len(colors)-1)]],
alpha=0.1, zorder=2)
# Main points
for i in range(0, n_points, 3): # Every 3rd point
ax.scatter(x[i], y[i], s=sizes[i], c=[colors[min(i, len(colors)-1)]],
alpha=alphas[i], edgecolors='white', linewidths=1, zorder=3)
# Start marker with glow
ax.scatter(x[0], y[0], s=300, c=COLORS['start'], alpha=0.2, zorder=4)
ax.scatter(x[0], y[0], s=150, c=COLORS['start'], edgecolors='white',
linewidths=3, zorder=5, marker='o')
ax.annotate('START', (x[0], y[0]), xytext=(15, 15), textcoords='offset points',
fontsize=10, fontweight='bold', color=COLORS['start'],
bbox=dict(boxstyle='round,pad=0.3', facecolor='white',
edgecolor=COLORS['start'], alpha=0.9))
# End marker with glow
ax.scatter(x[-1], y[-1], s=300, c=COLORS['end'], alpha=0.2, zorder=4)
ax.scatter(x[-1], y[-1], s=150, c=COLORS['end'], edgecolors='white',
linewidths=3, zorder=5, marker='o')
ax.annotate('END', (x[-1], y[-1]), xytext=(15, -20), textcoords='offset points',
fontsize=10, fontweight='bold', color=COLORS['end'],
bbox=dict(boxstyle='round,pad=0.3', facecolor='white',
edgecolor=COLORS['end'], alpha=0.9))
# Time indicators along path
for idx in [25, 50, 75]:
ax.annotate(f't={idx}', (x[idx], y[idx]), xytext=(10, 10),
textcoords='offset points', fontsize=8, color=COLORS['text_muted'],
alpha=0.7)
# === 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.set_xlim(-1, 11)
ax.set_ylim(-1, 11)
ax.set_aspect('equal')
ax.tick_params(axis='both', colors=COLORS['text_muted'], labelsize=9, length=0, pad=8)
ax.set_xlabel('X Position', fontsize=10, color=COLORS['text'], labelpad=10)
ax.set_ylabel('Y Position', fontsize=10, color=COLORS['text'], labelpad=10)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Pairwise Data
More Scatter Plot examples
☕