From a870d4db3d1fd4a7ab63f2cdab5658c4b35a2a82 Mon Sep 17 00:00:00 2001 From: sharkdp Date: Wed, 1 Apr 2020 09:31:55 +0200 Subject: [PATCH] Add --labels option for plot_whisker.py --- scripts/plot_whisker.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/plot_whisker.py b/scripts/plot_whisker.py index 8dcbe4d..fd9ad96 100755 --- a/scripts/plot_whisker.py +++ b/scripts/plot_whisker.py @@ -15,12 +15,16 @@ import matplotlib.pyplot as plt parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("file", help="JSON file with benchmark results") parser.add_argument("--title", help="Plot Title") +parser.add_argument("--labels", help="Comma-separated list of entries for the plot legend") args = parser.parse_args() with open(args.file) as f: results = json.load(f)["results"] -commands = [b["command"] for b in results] +if args.labels: + labels = args.labels.split(",") +else: + labels = [b["command"] for b in results] times = [b["times"] for b in results] boxplot = plt.boxplot(times, vert=True, patch_artist=True) @@ -31,7 +35,7 @@ for patch, color in zip(boxplot["boxes"], colors): patch.set_facecolor(color) plt.title(args.title) -plt.legend(handles=boxplot["boxes"], labels=commands, loc="best", fontsize="medium") +plt.legend(handles=boxplot["boxes"], labels=labels, loc="best", fontsize="medium") plt.ylabel("Time [s]") plt.ylim(0, None) plt.show()