Spaces:
Running
Running
Update functions/PitchPlotFunctions.py
Browse files
functions/PitchPlotFunctions.py
CHANGED
|
@@ -14,6 +14,8 @@ import matplotlib.patches as mpatches
|
|
| 14 |
import matplotlib.lines as mlines
|
| 15 |
from matplotlib.figure import Figure
|
| 16 |
import api_scraper
|
|
|
|
|
|
|
| 17 |
|
| 18 |
# Initialize the scraper
|
| 19 |
scraper = api_scraper.MLB_Scrape()
|
|
@@ -381,6 +383,17 @@ class PitchPlotFunctions:
|
|
| 381 |
# Set plot limits and labels
|
| 382 |
ax.set_xlim((-25, 25))
|
| 383 |
ax.set_ylim((-25, 25))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 384 |
ax.hlines(y=0, xmin=-50, xmax=50, color=colour_palette[8], alpha=0.5, linestyles='--', zorder=1)
|
| 385 |
ax.vlines(x=0, ymin=-50, ymax=50, color=colour_palette[8], alpha=0.5, linestyles='--', zorder=1)
|
| 386 |
ax.set_xlabel('Horizontal Break (in)', fontdict=font_properties_axes)
|
|
|
|
| 14 |
import matplotlib.lines as mlines
|
| 15 |
from matplotlib.figure import Figure
|
| 16 |
import api_scraper
|
| 17 |
+
from stuff_model import calculate_arm_angles as caa
|
| 18 |
+
|
| 19 |
|
| 20 |
# Initialize the scraper
|
| 21 |
scraper = api_scraper.MLB_Scrape()
|
|
|
|
| 383 |
# Set plot limits and labels
|
| 384 |
ax.set_xlim((-25, 25))
|
| 385 |
ax.set_ylim((-25, 25))
|
| 386 |
+
|
| 387 |
+
df_aa = caa.calculate_arm_angles(df,df['pitcher_id'][0])['arm_angle']
|
| 388 |
+
|
| 389 |
+
# Plot average arm angle
|
| 390 |
+
mean_arm_angle = df_aa.mean()
|
| 391 |
+
x_end = 30
|
| 392 |
+
y_end = x_end * np.tan(np.radians(mean_arm_angle))
|
| 393 |
+
ax.plot([0, x_end], [0, y_end], color='grey', linestyle='--', linewidth=2,zorder=0)
|
| 394 |
+
|
| 395 |
+
|
| 396 |
+
|
| 397 |
ax.hlines(y=0, xmin=-50, xmax=50, color=colour_palette[8], alpha=0.5, linestyles='--', zorder=1)
|
| 398 |
ax.vlines(x=0, ymin=-50, ymax=50, color=colour_palette[8], alpha=0.5, linestyles='--', zorder=1)
|
| 399 |
ax.set_xlabel('Horizontal Break (in)', fontdict=font_properties_axes)
|