Skip to content
Myr

Nicer whiskers plot

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

- add missing encoding when opening input file - add labels to x ticks, rotated by 45 deg - sort data by median, ascending

authored by Serpent7776 · committed by David Peter · parent 5493cf5 · Browse files · 1 file+7 added−1 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+7 added−1 removed

  • other:+7 added−1 removed

1 file+7 added−1 removed

modified:scripts/plot_whisker.py+7 added-1 removed
22 unmodified lines
23)2425args = parser.parse_args()2627with open(args.file) as f:27with open(args.file, encoding='utf-8') as f:28 results = json.load(f)["results"]2930if args.labels:31 labels = args.labels.split(",")32else:33 labels = [b["command"] for b in results]34times = [b["times"] for b in results]35medians = [b["median"] for b in results]3637indices = sorted(range(len(labels)), key=lambda k: medians[k])38labels = [labels[i] for i in indices]39times = [times[i] for i in indices]4041boxplot = plt.boxplot(times, vert=True, patch_artist=True)42cmap = plt.get_cmap("rainbow")43colors = [cmap(val / len(times)) for val in range(len(times))]44
4 unmodified lines
49 plt.title(args.title)50plt.legend(handles=boxplot["boxes"], labels=labels, loc="best", fontsize="medium")51plt.ylabel("Time [s]")52plt.ylim(0, None)53plt.xticks(list(range(1, len(labels)+1)), labels, rotation=45)54if args.output:55 plt.savefig(args.output)56else:57 plt.show()