From 9c32dc3241d47ba0fdfd6ef09819bc87a44e4612 Mon Sep 17 00:00:00 2001 From: Youngjoon Lee <5462944+youngjoon-lee@users.noreply.github.com> Date: Wed, 11 Sep 2024 08:50:51 +0900 Subject: [PATCH] use scientific notation if values are too large in the tables --- mixnet-rs/analysis/coeff.py | 4 ++-- mixnet-rs/analysis/latency.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mixnet-rs/analysis/coeff.py b/mixnet-rs/analysis/coeff.py index b5c62c6..82be17d 100644 --- a/mixnet-rs/analysis/coeff.py +++ b/mixnet-rs/analysis/coeff.py @@ -65,8 +65,8 @@ def analyze_versus(data: pd.DataFrame, x_field: str, outdir: str): columns = [x_field, "queue_type"] + flatten_fields table_data = max_paramset_data[columns].sort_values(by=[x_field, "queue_type"]) # Prepare to display values with only 2 decimal places - table_data[flatten_fields] = table_data[flatten_fields].applymap( - lambda x: f"{x:.2f}" + table_data[fields] = table_data[fields].map( + lambda x: f"{x:.2e}" if abs(x) >= 1e6 else f"{x:.2f}" ) # Display the table as a separate subplot fig_table, ax_table = plt.subplots( diff --git a/mixnet-rs/analysis/latency.py b/mixnet-rs/analysis/latency.py index 593faf7..2f620d5 100644 --- a/mixnet-rs/analysis/latency.py +++ b/mixnet-rs/analysis/latency.py @@ -52,7 +52,9 @@ def analyze_versus(data: pd.DataFrame, x_field: str, outdir: str): columns = [x_field, "queue_type"] + fields table_data = max_paramset_data[columns].sort_values(by=[x_field, "queue_type"]) # Prepare to display values with only 2 decimal places - table_data[fields] = table_data[fields].applymap(lambda x: f"{x:.2f}") + table_data[fields] = table_data[fields].map( + lambda x: f"{x:.2e}" if abs(x) >= 1e6 else f"{x:.2f}" + ) # Display the table as a separate subplot fig_table, ax_table = plt.subplots( figsize=(len(columns) * 1.8, len(table_data) * 0.3)