Spaces:
Running
Running
File size: 806 Bytes
16d5e2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 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 |