From ee3d921b2d73ec90f3a423016f97210ede4781d9 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Thu, 28 Nov 2019 14:37:57 +0100 Subject: support tikz plot using tikzplotlib --- src/benchmark.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/benchmark.py') diff --git a/src/benchmark.py b/src/benchmark.py index 15c4fee..cbc59eb 100644 --- a/src/benchmark.py +++ b/src/benchmark.py @@ -612,7 +612,12 @@ class Benchmark: plt.xlabel(eval(xlabel)) plt.ylabel(eval(ylabel)) plt.title(eval(title)) - plt.savefig(os.path.join(sumdir, ".".join([self.name, filepostfix, file_ext]))) + figname = os.path.join(sumdir, f"{self.name}.{filepostfix}.{file_ext}") + if figname.endswith(".tex"): + import tikzplotlib + tikzplotlib.save(figname) + else: + plt.savefig(figname) plt.clf() def barplot_single_arg(self, yval, ylabel="'y-label'", xlabel="'x-label'", @@ -661,7 +666,12 @@ class Benchmark: plt.xlabel(eval(xlabel)) plt.ylabel(eval(ylabel)) plt.title(eval(title)) - plt.savefig(os.path.join(sumdir, ".".join([self.name, filepostfix, file_ext]))) + figname = os.path.join(sumdir, f"{self.name}.{filepostfix}.{file_ext}") + if figname.endswith(".tex"): + import tikzplotlib + tikzplotlib.save(figname) + else: + plt.savefig(figname) plt.clf() def plot_fixed_arg(self, yval, ylabel="'y-label'", xlabel="loose_arg", @@ -702,8 +712,13 @@ class Benchmark: plt.xlabel(eval(xlabel)) plt.ylabel(eval(ylabel)) plt.title(eval(title)) - plt.savefig(os.path.join(sumdir, - f"{self.name}.{arg}.{arg_value}.{filepostfix}.{file_ext}")) + figname = os.path.join(sumdir, + f"{self.name}.{arg}.{arg_value}.{filepostfix}.{file_ext}") + if figname.endswith(".tex"): + import tikzplotlib + tikzplotlib.save(figname) + else: + plt.savefig(figname) plt.clf() def export_facts_to_file(self, comment_symbol, f): -- cgit v1.2.3