Skip to content
Myr

Add --labels option for plot_whisker.py

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by sharkdp · committed by sharkdp · parent 40ceadb · Browse files · 1 file+6 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−2 removed

  • other:+6 added−2 removed

1 file+6 added−2 removed

modified:scripts/plot_whisker.py+6 added-2 removed
13 unmodified lines
1415parser = argparse.ArgumentParser(description=__doc__)16parser.add_argument("file", help="JSON file with benchmark results")17parser.add_argument("--title", help="Plot Title")18parser.add_argument("--labels", help="Comma-separated list of entries for the plot legend")19args = parser.parse_args()2021with open(args.file) as f:22 results = json.load(f)["results"]2324if args.labels:25 labels = args.labels.split(",")26else:23commands = [b["command"] for b in results]27 labels = [b["command"] for b in results]28times = [b["times"] for b in results]2930boxplot = plt.boxplot(times, vert=True, patch_artist=True)31cmap = plt.cm.get_cmap("rainbow")
2 unmodified lines
34for patch, color in zip(boxplot["boxes"], colors):35 patch.set_facecolor(color)3637plt.title(args.title)34plt.legend(handles=boxplot["boxes"], labels=commands, loc="best", fontsize="medium")38plt.legend(handles=boxplot["boxes"], labels=labels, loc="best", fontsize="medium")39plt.ylabel("Time [s]")40plt.ylim(0, None)41plt.show()