From 3fd6859acb4aacec84e8eba8c30f11fa6edb265c Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Tue, 11 Feb 2020 12:32:37 +0100 Subject: use allocbench colors in pgfplot the used colors consist of the allocator name followed by '_color'. The colors are defined using xcolors providecolor command which does not override existing names. --- src/benchmark.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/benchmark.py b/src/benchmark.py index c572618..29442d1 100644 --- a/src/benchmark.py +++ b/src/benchmark.py @@ -9,6 +9,7 @@ import os import subprocess from time import sleep +import matplotlib import matplotlib.pyplot as plt import numpy as np @@ -983,16 +984,21 @@ class Benchmark: s =\ """\\documentclass{standalone} \\usepackage{pgfplots} +\\usepackage{xcolor} """ - for alloc in allocators: - s += f"\\begin{{filecontents*}}{{{alloc}.dat}}\n" + for alloc_name, alloc_dict in allocators.items(): + s += f"\\begin{{filecontents*}}{{{alloc_name}.dat}}\n" for i, perm in enumerate(perms): - x = self._eval_with_stat(xval, alloc, perm, "mean") - y = self._eval_with_stat(yval, alloc, perm, "mean") + x = self._eval_with_stat(xval, alloc_name, perm, "mean") + y = self._eval_with_stat(yval, alloc_name, perm, "mean") s += f"{x} {y}\n" s += "\\end{filecontents*}\n" + # define color + rgb = matplotlib.colors.to_rgb(alloc_dict["color"]) + s += f"\\providecolor{{{alloc_name}-color}}{{rgb}}{{{rgb[0]},{rgb[1]},{rgb[2]}}}\n" + s +=\ f""" \\begin{{document}} @@ -1004,9 +1010,9 @@ f""" ] """ - for alloc in allocators: - # s += f"\\addplot [color{i}] table {{{alloc_name}.dat}}" - s += f"\t\\addplot table {{{alloc}.dat}};\n" + for alloc_name in allocators: + s += f"\\addplot [{alloc_name}-color] table {{{alloc_name}.dat}};\n" + # s += f"\t\\addplot table {{{alloc_name}.dat}};\n" s +=\ """\\end{axis} -- cgit v1.2.3