3D Scatter

Soccer Player Movement Analysis

Sports analytics visualization showing player positions over time with speed indicated.

Output
Soccer Player Movement Analysis
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(456)

# Soccer player tracking data (90 min match)
n_positions = 250

# Simulate player movement patterns
t = np.linspace(0, 90, n_positions)

# Player position on field
x = 50 + 30 * np.sin(t / 15) + np.random.normal(0, 5, n_positions)  # Field width
y = 35 + 25 * np.sin(t / 10 + 1) + np.random.normal(0, 8, n_positions)  # Field length

# Speed (z-axis)
speed = np.abs(np.diff(np.sqrt(np.diff(x)**2 + np.diff(y)**2)))
speed = np.concatenate([[0, 0], speed])
speed = speed * 10 + np.random.exponential(2, n_positions)

fig = plt.figure(figsize=(10, 8), facecolor='#ffffff')
ax = fig.add_subplot(111, projection='3d', facecolor='#ffffff')

scatter = ax.scatter(x, y, t, c=speed, cmap='YlOrRd', s=speed*3+10, 
                     alpha=0.7, edgecolors='#374151', linewidths=0.3)

cbar = plt.colorbar(scatter, ax=ax, shrink=0.6, pad=0.1)
cbar.set_label('Speed (km/h)', color='#1f2937', fontsize=10)
cbar.ax.tick_params(colors='#6b7280')

ax.set_xlabel('Field X (m)', color='#1f2937', fontsize=10)
ax.set_ylabel('Field Y (m)', color='#1f2937', fontsize=10)
ax.set_zlabel('Time (min)', color='#1f2937', fontsize=10)
ax.set_title('Soccer Player Movement Analysis', color='#1f2937', fontsize=14, fontweight='bold', pad=20)

ax.tick_params(colors='#6b7280', labelsize=8)
ax.xaxis.pane.fill = False
ax.yaxis.pane.fill = False
ax.zaxis.pane.fill = False
ax.xaxis.pane.set_edgecolor('#e5e7eb')
ax.yaxis.pane.set_edgecolor('#e5e7eb')
ax.zaxis.pane.set_edgecolor('#e5e7eb')

ax.view_init(elev=20, azim=45)
plt.tight_layout()
plt.show()
Library

Matplotlib

Category

3D Charts

Did this help you?

Support PyLucid to keep it free & growing

Support