summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerpent7776 <Serpent7776@gmail.com>2024-03-02 16:32:39 +0100
committerDavid Peter <sharkdp@users.noreply.github.com>2024-03-14 08:26:35 +0100
commit5c9d7a8b1ee608838e360755aa2e378bce0eb286 (patch)
treefa8f5328c18663fed26601c1123e1d8cf064a331
parent5493cf5039c1c19081a8e2a2d74029ae1a581b3e (diff)
Nicer whiskers plot
- add missing encoding when opening input file - add labels to x ticks, rotated by 45 deg - sort data by median, ascending
-rwxr-xr-xscripts/plot_whisker.py8
1 files changed, 7 insertions, 1 deletions
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: