diff --git a/scripts/plot_whisker.py b/scripts/plot_whisker.py index 701078a..044f84b 100755 --- a/scripts/plot_whisker.py +++ b/scripts/plot_whisker.py @@ -24,7 +24,7 @@ parser.add_argument( args = parser.parse_args() -with open(args.file) as f: +with open(args.file, encoding='utf-8') as f: results = json.load(f)["results"] if args.labels: @@ -32,6 +32,11 @@ if args.labels: else: labels = [b["command"] for b in results] times = [b["times"] for b in results] +medians = [b["median"] for b in results] + +indices = sorted(range(len(labels)), key=lambda k: medians[k]) +labels = [labels[i] for i in indices] +times = [times[i] for i in indices] boxplot = plt.boxplot(times, vert=True, patch_artist=True) cmap = plt.get_cmap("rainbow") @@ -45,6 +50,7 @@ if args.title: plt.legend(handles=boxplot["boxes"], labels=labels, loc="best", fontsize="medium") plt.ylabel("Time [s]") plt.ylim(0, None) +plt.xticks(list(range(1, len(labels)+1)), labels, rotation=45) if args.output: plt.savefig(args.output) else: