Spaces:
Running
Running
| from __future__ import annotations | |
| import pandas as pd | |
| import plotly.express as px | |
| import plotly.graph_objects as go | |
| def create_total_bases_distribution(sim_df: pd.DataFrame, player_name: str) -> go.Figure: | |
| if sim_df.empty: | |
| return go.Figure() | |
| fig = px.histogram( | |
| sim_df, | |
| x="total_bases", | |
| nbins=5, | |
| title=f"{player_name} Simulated Total Bases Distribution", | |
| ) | |
| fig.update_layout(template="plotly_dark") | |
| return fig | |
| def create_hr_distribution(sim_df: pd.DataFrame, player_name: str) -> go.Figure: | |
| if sim_df.empty: | |
| return go.Figure() | |
| fig = px.histogram( | |
| sim_df, | |
| x="hr", | |
| nbins=2, | |
| title=f"{player_name} Simulated Home Run Outcomes", | |
| ) | |
| fig.update_layout(template="plotly_dark") | |
| return fig |