Syntrex commited on
Commit
72bdf20
·
verified ·
1 Parent(s): 160bca6

Rename visualization/pitcher.txt to visualization/pitcher.py

Browse files
visualization/pitcher.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import pandas as pd
4
+ import plotly.express as px
5
+ import plotly.graph_objects as go
6
+
7
+
8
+ def create_pitch_movement_chart(df: pd.DataFrame) -> go.Figure:
9
+ if df.empty or "pfx_x" not in df.columns or "pfx_z" not in df.columns:
10
+ return go.Figure()
11
+
12
+ color_col = "pitch_type" if "pitch_type" in df.columns else None
13
+
14
+ fig = px.scatter(
15
+ df,
16
+ x="pfx_x",
17
+ y="pfx_z",
18
+ color=color_col,
19
+ title="Pitch Movement",
20
+ labels={"pfx_x": "Horizontal Break", "pfx_z": "Vertical Break"},
21
+ opacity=0.75,
22
+ )
23
+ fig.update_layout(template="plotly_dark")
24
+ return fig
visualization/pitcher.txt DELETED
File without changes