From 16d9d8967df987f4a6fcf3fd8e949666094e5478 Mon Sep 17 00:00:00 2001 From: Lizzzka007 <gashchuk2011@mail.ru> Date: Fri, 23 Jun 2023 01:33:36 +0300 Subject: [PATCH] Add multiple plot, need check --- plotter/Plotter.py | 28 ++++++++++++++++++++++++++-- plotter/__init__.py | 2 +- plotter/main.py | 6 ++++++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/plotter/Plotter.py b/plotter/Plotter.py index 0620550..f171297 100755 --- a/plotter/Plotter.py +++ b/plotter/Plotter.py @@ -88,7 +88,7 @@ class Plotter: if args.func != self.dump: - if args.func == self.plot or args.func == self.ani_plot: + if args.func == self.plot or args.func == self.ani_plot or args.func == self.multiple_plot: self.ndim = 1 elif args.func == self.plot_contour or args.func == self.ani_plot_contour: self.ndim = 2 @@ -113,11 +113,31 @@ class Plotter: plt.legend(self.var) plt.xlabel(x_name, fontsize=10, fontweight='bold') + plt.xlabel(y_name, fontsize=10, fontweight='bold') if self.if_manual_plot: plt.show() else: plt.close(fig) if self.if_save_result: fig.savefig(self.out + self.oname[0]) + def __multiple_plot(self): + os.system("mkdir -p " + self.out) + x_name = self.file_column_names[0] + + fig = plt.figure() + + for data in self.file_data: + for y_name in self.var: + plt.plot(data.data[x_name], data.data[y_name], linewidth=4) + plt.legend(self.filename) + plt.xlabel(x_name, fontsize=10, fontweight='bold') + plt.ylabel(y_name, fontsize=10, fontweight='bold') + + if self.if_manual_plot: plt.show() + else: plt.close(fig) + if self.if_save_result: fig.savefig(self.out + self.oname[0]) + + + def __get_min_max_ax(self): min_max_var_vals = {var : [] for var in self.var} @@ -432,4 +452,8 @@ class Plotter: def get_data(self): return_data = [copy.deepcopy(data.data) for data in self.file_data] - return return_data \ No newline at end of file + return return_data + + def multiple_plot(self): + self.__get_min_max_ax() + self.__multiple_plot() \ No newline at end of file diff --git a/plotter/__init__.py b/plotter/__init__.py index 6f6cd90..4c896fe 100755 --- a/plotter/__init__.py +++ b/plotter/__init__.py @@ -8,4 +8,4 @@ from .main import ani_plot_contour from .main import avg_plot from .main import plot_diff from .main import get_data - +from .main import multiple_plot diff --git a/plotter/main.py b/plotter/main.py index 2d165cb..7c6eb63 100755 --- a/plotter/main.py +++ b/plotter/main.py @@ -20,6 +20,12 @@ def plot(filename, out = './', oname = 'fig.png', var=[None], mval=[None], min_y Plot.set(args, if_manual_plot=manual_plot, if_save_result=save_result) Plot.plot() +def multiple_plot(filename, out = './', oname = 'fig.png', var=[None], mval=[None], min_y = None, max_y = None): + Plot = Plotter() + args = Args(filename, Plot.multiple_plot, var=var, mval=mval, oname=oname, out=out) + Plot.set(args, if_manual_plot=manual_plot, if_save_result=save_result) + Plot.multiple_plot() + def ani_plot(filename, out = './', oname = 'fig.gif', var=[None], mval=[None], min_y = None, max_y = None): pp = str(PurePath(filename).parent) + '/' name = str(PurePath(filename).name ) -- GitLab