Syntrex commited on
Commit
16d5e2d
·
verified ·
1 Parent(s): ee18e64

Rename visualization/simulation.txt to visualization/simulation.py

Browse files
visualization/simulation.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_total_bases_distribution(sim_df: pd.DataFrame, player_name: str) -> go.Figure:
9
+ if sim_df.empty:
10
+ return go.Figure()
11
+
12
+ fig = px.histogram(
13
+ sim_df,
14
+ x="total_bases",
15
+ nbins=5,
16
+ title=f"{player_name} Simulated Total Bases Distribution",
17
+ )
18
+ fig.update_layout(template="plotly_dark")
19
+ return fig
20
+
21
+
22
+ def create_hr_distribution(sim_df: pd.DataFrame, player_name: str) -> go.Figure:
23
+ if sim_df.empty:
24
+ return go.Figure()
25
+
26
+ fig = px.histogram(
27
+ sim_df,
28
+ x="hr",
29
+ nbins=2,
30
+ title=f"{player_name} Simulated Home Run Outcomes",
31
+ )
32
+ fig.update_layout(template="plotly_dark")
33
+ return fig
visualization/simulation.txt DELETED
File without changes