Update functions/pitch_summary_functions.py
Browse files
functions/pitch_summary_functions.py
CHANGED
|
@@ -19,6 +19,8 @@ from matplotlib.offsetbox import OffsetImage, AnnotationBbox
|
|
| 19 |
import matplotlib.pyplot as plt
|
| 20 |
import matplotlib.gridspec as gridspec
|
| 21 |
import PIL
|
|
|
|
|
|
|
| 22 |
|
| 23 |
|
| 24 |
### PITCH COLOURS ###
|
|
@@ -394,6 +396,14 @@ def break_plot(df: pl.DataFrame, ax: plt.Axes):
|
|
| 394 |
ax.set_xlim((-25, 25))
|
| 395 |
ax.set_ylim((-25, 25))
|
| 396 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 397 |
# Add horizontal and vertical lines
|
| 398 |
ax.hlines(y=0, xmin=-50, xmax=50, color=colour_palette[8], alpha=0.5, linestyles='--', zorder=1)
|
| 399 |
ax.vlines(x=0, ymin=-50, ymax=50, color=colour_palette[8], alpha=0.5, linestyles='--', zorder=1)
|
|
|
|
| 19 |
import matplotlib.pyplot as plt
|
| 20 |
import matplotlib.gridspec as gridspec
|
| 21 |
import PIL
|
| 22 |
+
from stuff_model import calculate_arm_angles as caa
|
| 23 |
+
|
| 24 |
|
| 25 |
|
| 26 |
### PITCH COLOURS ###
|
|
|
|
| 396 |
ax.set_xlim((-25, 25))
|
| 397 |
ax.set_ylim((-25, 25))
|
| 398 |
|
| 399 |
+
df_aa = caa.calculate_arm_angles(df,df['pitcher_id'][0])['arm_angle']
|
| 400 |
+
# Plot average arm angle
|
| 401 |
+
mean_arm_angle = df_aa.mean()
|
| 402 |
+
x_end = 30
|
| 403 |
+
y_end = x_end * np.tan(np.radians(mean_arm_angle))
|
| 404 |
+
ax.plot([0, x_end], [0, y_end], color='grey', linestyle='--', linewidth=2,zorder=0,alpha=0.7)
|
| 405 |
+
|
| 406 |
+
|
| 407 |
# Add horizontal and vertical lines
|
| 408 |
ax.hlines(y=0, xmin=-50, xmax=50, color=colour_palette[8], alpha=0.5, linestyles='--', zorder=1)
|
| 409 |
ax.vlines(x=0, ymin=-50, ymax=50, color=colour_palette[8], alpha=0.5, linestyles='--', zorder=1)
|