From 11075f01cf629a6e14cac9637c87709f36af3ab6 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 25 Jun 2016 05:52:06 +0300 Subject: scientific notation by default in plots --- algorithms/params.py | 1 + algorithms/plotter.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'algorithms') diff --git a/algorithms/params.py b/algorithms/params.py index a66f7a2..cc35e33 100644 --- a/algorithms/params.py +++ b/algorithms/params.py @@ -101,6 +101,7 @@ class AlgorithmParameters: plot_builder.show_grid() plot_builder.set_xlabel(self._format_plot_xlabel()) plot_builder.set_ylabel(self._format_plot_ylabel()) + plot_builder.set_yticklabels_scientific() plot_builder.set_title(self._format_plot_title()) xs, ys = self.measure_running_time() plot_builder.plot(xs, ys) diff --git a/algorithms/plotter.py b/algorithms/plotter.py index 048894f..58ee941 100644 --- a/algorithms/plotter.py +++ b/algorithms/plotter.py @@ -13,6 +13,10 @@ class PlotBuilder: def set_ylabel(s): plt.ylabel(s) + @staticmethod + def set_yticklabels_scientific(): + plt.ticklabel_format(style='sci', axis='y', scilimits=(0, 0)) + @staticmethod def show_grid(): plt.grid() @@ -34,5 +38,8 @@ class PlotBuilder: plt.show() @staticmethod - def save(output_path): - plt.savefig(output_path)#, bbox_inches='tight') + def save(output_path, tight=False): + if tight: + plt.savefig(output_path, bbox_inches='tight') + else: + plt.savefig(output_path) -- cgit v1.2.3