-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrajectory.py
More file actions
31 lines (26 loc) · 1.17 KB
/
Copy pathtrajectory.py
File metadata and controls
31 lines (26 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import matplotlib.pyplot as plt
import numpy as np
# Simulate pitch trajectory data for various pitch types
np.random.seed(42)
# Define pitch types and their typical movement patterns (simplified)
pitch_types = {
"4-Seam Fastball": {"color": "red", "vx": np.random.normal(0, 0.5, 10), "vy": np.linspace(0, -18, 10)},
"Sinker": {"color": "blue", "vx": np.random.normal(0, 0.3, 10), "vy": np.linspace(0, -20, 10)},
"Slider": {"color": "green", "vx": np.linspace(-1.5, -3, 10), "vy": np.linspace(0, -14, 10)},
"Curveball": {"color": "purple", "vx": np.linspace(0.2, -0.8, 10), "vy": np.linspace(0, -12, 10)},
"Changeup": {"color": "orange", "vx": np.random.normal(0, 0.4, 10), "vy": np.linspace(0, -16, 10)}
}
# Create the plot
plt.figure(figsize=(10, 6))
for pitch, data in pitch_types.items():
x = np.cumsum(data["vx"])
y = data["vy"]
plt.plot(x, y, label=pitch, color=data["color"], linewidth=2)
plt.gca().invert_yaxis() # Invert to represent pitch going downward
plt.title("Simulated Pitch Trajectories by Pitch Type")
plt.xlabel("Horizontal Movement (inches)")
plt.ylabel("Vertical Drop (inches)")
plt.legend()
plt.grid(True)
plt.tight_layout()
plt.show()