Syntrex commited on
Commit
ee18e64
·
verified ·
1 Parent(s): 164ade2

Rename visualization/matchup.txt to visualization/matchup.py

Browse files
visualization/matchup.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_matchup_score_chart(df: pd.DataFrame) -> go.Figure:
9
+ if df.empty:
10
+ return go.Figure()
11
+
12
+ fig = px.bar(
13
+ df,
14
+ x="player_name",
15
+ y="matchup_score",
16
+ title="Best Batter vs Pitcher Matchups",
17
+ )
18
+ fig.update_layout(template="plotly_dark", xaxis_title="", yaxis_title="Matchup Score")
19
+ return fig
20
+
21
+
22
+ def create_hit_hr_chart(df: pd.DataFrame) -> go.Figure:
23
+ if df.empty:
24
+ return go.Figure()
25
+
26
+ fig = px.scatter(
27
+ df,
28
+ x="hit_prob",
29
+ y="hr_prob",
30
+ hover_name="player_name",
31
+ size="matchup_score",
32
+ title="Hit Probability vs Home Run Probability",
33
+ )
34
+ fig.update_layout(template="plotly_dark")
35
+ return fig
visualization/matchup.txt DELETED
File without changes