Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgiving committed Jan 3, 2025
1 parent 7d71232 commit 4ddd30c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
22 changes: 19 additions & 3 deletions report/charts/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import json
from collections import defaultdict
from typing import Dict, List
from typing import Any, Dict, List

from matplotlib.axes import Axes
import numpy as np
from matplotlib import pyplot as plt

Expand All @@ -17,6 +18,16 @@ def select_metric(all_data: Dict[str, List[Dict[str, float]]], metric: str) -> D
return data


def configure_x_axis(axes: Axes, json_data: Dict[str, Any]) -> Axes:
axes.set_xticks(ticks=range(len(json_data['xticks'])))
axes.set_xticklabels(json_data['xticks'])

xlabel = json_data.get('xlabel')
if xlabel is not None:
axes.set_xlabel(xlabel=xlabel)
return axes


def main() -> None:
args = ChartArgumentParser(underscores_to_dashes=True).parse_args()
with args.config.open() as file:
Expand All @@ -40,14 +51,19 @@ def main() -> None:
config_name = json_data['name']
chart_name = args.save_path / f'{config_name}_{metric}.png'
prepared_data = select_metric(data, metric)

figure = plt.figure(figsize=(4,4), dpi=800)
axes = figure.gca()

for line_name, values in prepared_data.items():
axes.plot(values, label=line_name)

axes.legend()
axes.set_xticks(ticks=np.linspace(0, 3, 4))
axes.set_xticklabels(['0', '0.1', '0.15', '0.2'])

axes = configure_x_axis(axes, json_data)

axes.set_title(process_metric_name(metric))

figure.tight_layout()
figure.savefig(chart_name)
plt.close(figure)
Expand Down
4 changes: 3 additions & 1 deletion report/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ Below is an example of a configuration file (config.json) to customize the behav
"ari",
"ami",
"time",
]
],
"xticks": ["2", "4", "8", "16", "15"],
"xlabel": "[Optional] Name of X Axis"
}
```

Expand Down

0 comments on commit 4ddd30c

Please sign in to comment.