Skip to content

Commit

Permalink
Modified code to include numbers on top of bar plots
Browse files Browse the repository at this point in the history
  • Loading branch information
snova-rodrigom committed Oct 1, 2024
1 parent 52781f1 commit 784bc19
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions benchmarking/streamlit/streamlit_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ def plot_dataframe_summary(df_req_info: pd.DataFrame) -> Figure:
var_name='Side type',
value_name='Total throughput (tokens per second)',
)

df_melted['Total throughput (tokens per second)'] = df_melted['Total throughput (tokens per second)'].round(2)

df_melted['Batch size'] = [str(x) for x in df_melted['Batch size']]
fig = px.bar(
df_melted,
Expand All @@ -61,7 +64,11 @@ def plot_dataframe_summary(df_req_info: pd.DataFrame) -> Figure:
color='Side type',
barmode='group',
color_discrete_sequence=['#325c8c', '#ee7625'],
text='Total throughput (tokens per second)',
)

fig.update_traces(textposition='outside') # Set text position outside bars

fig.update_layout(
title_text='Total throughput per batch size',
template='plotly_dark',
Expand Down Expand Up @@ -114,14 +121,16 @@ def plot_client_vs_server_barplots(
go.Bar(
x=xgroups,
y=[0 for _ in xgroups],
base=[valsl[i][1] for i in xgroups],
base=[round(valsl[i][1],2) for i in xgroups],
customdata=[legend_labels[0] for _ in xgroups],
marker={'color': '#325c8c', 'line': {'color': '#325c8c', 'width': 2}},
offsetgroup=0,
legendgroup=legend_labels[0],
name=legend_labels[0],
showlegend=False,
hovertemplate='<extra></extra><b>%{customdata}</b> median: %{base:.2f}',
text=[round(valsl[i][1],2) for i in xgroups],
textposition='outside',
)
)
fig.add_trace(
Expand All @@ -142,14 +151,16 @@ def plot_client_vs_server_barplots(
go.Bar(
x=xgroups,
y=[0 for _ in xgroups],
base=[valsr[i][1] for i in xgroups],
base=[round(valsr[i][1],2) for i in xgroups],
customdata=[legend_labels[1] for _ in xgroups],
marker={'color': '#ee7625', 'line': {'color': '#ee7625', 'width': 2}},
offsetgroup=1,
legendgroup=legend_labels[1],
name=legend_labels[1],
showlegend=False,
hovertemplate='<extra></extra><b>%{customdata}</b> median: %{base:.2f}',
text=[round(valsr[i][1],2) for i in xgroups],
textposition='outside'
)
)
fig.add_trace(
Expand Down

0 comments on commit 784bc19

Please sign in to comment.