diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-06-24 01:54:13 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-06-24 01:54:13 +0300 |
commit | 82a674e409fce161299efeb43e1176f869af64af (patch) | |
tree | 3b544bd96688f3847233e011452c754c38755116 /algorithms/plotter.py | |
parent | add Pylint configuration (diff) | |
download | sorting-algorithms-82a674e409fce161299efeb43e1176f869af64af.tar.gz sorting-algorithms-82a674e409fce161299efeb43e1176f869af64af.zip |
major refactoring
With the focus on (re)usability.
That includes adding separate modules for plotting, input generation
and things like that.
Diffstat (limited to 'algorithms/plotter.py')
-rw-r--r-- | algorithms/plotter.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/algorithms/plotter.py b/algorithms/plotter.py new file mode 100644 index 0000000..048894f --- /dev/null +++ b/algorithms/plotter.py @@ -0,0 +1,38 @@ +# Copyright 2016 Egor Tensin <Egor.Tensin@gmail.com> +# This file is licensed under the terms of the MIT License. +# See LICENSE.txt for details. + +import matplotlib.pyplot as plt + +class PlotBuilder: + @staticmethod + def set_xlabel(s): + plt.xlabel(s) + + @staticmethod + def set_ylabel(s): + plt.ylabel(s) + + @staticmethod + def show_grid(): + plt.grid() + + @staticmethod + def set_title(s): + plt.title(s) + + @staticmethod + def set_suptitle(s): + plt.suptitle(s) + + @staticmethod + def plot(xs, ys): + plt.plot(xs, ys) + + @staticmethod + def show(): + plt.show() + + @staticmethod + def save(output_path): + plt.savefig(output_path)#, bbox_inches='tight') |