aboutsummaryrefslogtreecommitdiff
path: root/src/plots.py
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2020-02-20 14:45:33 +0100
committerFlorian Fischer <florian.fl.fischer@fau.de>2020-02-20 14:45:33 +0100
commit1a3024f0ff5628bff535767fb4f044233a01b822 (patch)
treebc6250bf6e75880ce5bb80064499e24ae3172fc4 /src/plots.py
parent53b51b8522feb9b82899245c7fd52fa341fd9587 (diff)
downloadallocbench-1a3024f0ff5628bff535767fb4f044233a01b822.tar.gz
allocbench-1a3024f0ff5628bff535767fb4f044233a01b822.zip
add support for pgf bar plots and error bars
Diffstat (limited to 'src/plots.py')
-rw-r--r--src/plots.py32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/plots.py b/src/plots.py
index 8345181..a5bd32e 100644
--- a/src/plots.py
+++ b/src/plots.py
@@ -513,8 +513,9 @@ def pgfplot_legend(bench, sumdir="", file_name="pgfplot_legend"):
with open(os.path.join(sumdir, f"{file_name}.tex"), "w") as legend_file:
print(tex, file=legend_file)
-def pgfplot_linear(bench, perms, xexpr, yexpr, ylabel="y-label", xlabel="x-label",
- title="default title", postfix="", sumdir="", scale=None):
+def pgfplot(bench, perms, xexpr, yexpr, bar=False,
+ ylabel="y-label", xlabel="x-label", title="default title",
+ postfix="", sumdir="", scale=None, error_bars=True):
allocators = bench.results["allocators"]
perms = list(perms)
@@ -527,10 +528,20 @@ def pgfplot_linear(bench, perms, xexpr, yexpr, ylabel="y-label", xlabel="x-label
for alloc_name, alloc_dict in allocators.items():
tex += f"\\begin{{filecontents*}}{{{alloc_name}.dat}}\n"
+ tex += "x y"
+ if error_bars:
+ tex += " error"
+ tex += "\n"
+
for perm in perms:
xval = _eval_with_stat(bench, xexpr, alloc_name, perm, "mean")
yval = _eval_with_stat(bench, yexpr, alloc_name, perm, "mean")
- tex += f"{xval} {yval}\n"
+ tex += f"{xval} {yval}"
+ if error_bars:
+ error = _eval_with_stat(bench, yexpr, alloc_name, perm, "std")
+ tex += f" {error}"
+ tex += "\n"
+
tex += "\\end{filecontents*}\n"
# define color
@@ -553,13 +564,20 @@ f"""
\\begin{{axis}}[
\ttitle={{{title}}},
\txlabel={{{xlabel}}},
-\tylabel={{{ylabel}}},
-]
-"""
+\tylabel={{{ylabel}}},"""
+ if bar:
+ tex += "\n\tybar,\n"
+ tex += "]\n"
for alloc_name in allocators:
# tex += f"\\addplot [{alloc_name}-color] table {{{alloc_name}.dat}};\n"
- tex += f"\t\\addplot+[{alloc_name}] table {{{alloc_name}.dat}};\n"
+ tex += f"\t\\addplot+[{alloc_name},"
+ if error_bars:
+ tex += "\n\terror bars/.cd, y dir=both, y explicit,\n\t"
+ tex += f"] table"
+ if error_bars:
+ tex += "[y error=error]"
+ tex += f" {{{alloc_name}.dat}};\n"
tex +=\
"""\\end{axis}