Update functions/pitch_summary_functions.py
Browse files
functions/pitch_summary_functions.py
CHANGED
|
@@ -19,6 +19,7 @@ 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 +395,17 @@ 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)
|
|
@@ -401,7 +413,7 @@ def break_plot(df: pl.DataFrame, ax: plt.Axes):
|
|
| 401 |
# Set axis labels and title
|
| 402 |
ax.set_xlabel('Horizontal Break (in)', fontdict=font_properties_axes)
|
| 403 |
ax.set_ylabel('Induced Vertical Break (in)', fontdict=font_properties_axes)
|
| 404 |
-
ax.set_title("Pitch Breaks", fontdict=font_properties_titles)
|
| 405 |
|
| 406 |
# Remove legend
|
| 407 |
ax.get_legend().remove()
|
|
|
|
| 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 |
### PITCH COLOURS ###
|
|
|
|
| 395 |
ax.set_xlim((-25, 25))
|
| 396 |
ax.set_ylim((-25, 25))
|
| 397 |
|
| 398 |
+
|
| 399 |
+
df_aa = caa.calculate_arm_angles(df,df['pitcher_id'][0])['arm_angle']
|
| 400 |
+
|
| 401 |
+
# Plot average arm angle
|
| 402 |
+
mean_arm_angle = df_aa.mean()
|
| 403 |
+
x_end = 30
|
| 404 |
+
y_end = x_end * np.tan(np.radians(mean_arm_angle))
|
| 405 |
+
ax.plot([0, x_end], [0, y_end], color='grey', linestyle='--', linewidth=2,zorder=0)
|
| 406 |
+
|
| 407 |
+
|
| 408 |
+
|
| 409 |
# Add horizontal and vertical lines
|
| 410 |
ax.hlines(y=0, xmin=-50, xmax=50, color=colour_palette[8], alpha=0.5, linestyles='--', zorder=1)
|
| 411 |
ax.vlines(x=0, ymin=-50, ymax=50, color=colour_palette[8], alpha=0.5, linestyles='--', zorder=1)
|
|
|
|
| 413 |
# Set axis labels and title
|
| 414 |
ax.set_xlabel('Horizontal Break (in)', fontdict=font_properties_axes)
|
| 415 |
ax.set_ylabel('Induced Vertical Break (in)', fontdict=font_properties_axes)
|
| 416 |
+
ax.set_title(f"Pitch Breaks - Arm Angle: {mean_arm_angle:.0f}°", fontdict=font_properties_titles)
|
| 417 |
|
| 418 |
# Remove legend
|
| 419 |
ax.get_legend().remove()
|