diff --git a/plotter/Plotter.py b/plotter/Plotter.py index f26c1671046802609937337f2d4bc267dcfc9275..f1aa3ef3af6bc5c90b6dfed0bbe2d49ff947d8a7 100755 --- a/plotter/Plotter.py +++ b/plotter/Plotter.py @@ -7,6 +7,7 @@ import natsort import imageio from .ProcData import ProcData import copy +from matplotlib.cm import ScalarMappable class Plotter: ani_pngs_dir = "plotter_lib_pngs/" @@ -183,7 +184,7 @@ class Plotter: for file_name in png_names: images.append(imageio.v2.imread(file_name)) - imageio.mimsave(self.oname[0], images, fps = 5) + imageio.mimsave(self.oname[0], images, duration=20, loop = 0) shutil.rmtree(self.ani_pngs_dir) def __plot_contour(self): @@ -197,10 +198,22 @@ class Plotter: else: fig_names = self.oname fig_end = "" + + if self.max_y == None: + max_val = {var:self.min_max_var_vals[var][1] for var in self.var} + else: + max_val = {var:self.max_y[i] for var, i in zip(self.var, list(range(len(self.var))))} + + if self.min_y == None: + min_val = {var:self.min_max_var_vals[var][0] for var in self.var} + else: + min_val = {var:self.min_y[i] for var, i in zip(self.var, list(range(len(self.var))))} + + # print(min_val, max_val) for i in range(self.fig_count): fig,ax=plt.subplots(1,1) - + if self.title == None: title = self.var[i] else: @@ -210,7 +223,10 @@ class Plotter: Y = self.file_data[0].data[y_name] Z = self.file_data[0].data[self.var[i]] - cp = ax.contourf(X, Y, Z) + vmin = min_val[self.var[i]]; vmax = max_val[self.var[i]]; + levels = np.linspace(vmin, vmax, 25) + cp = ax.contourf(X, Y, Z, vmin=vmin, vmax=vmax, levels=levels) + # fig.colorbar(ScalarMappable(norm=cp.norm, cmap=cp.cmap),ticks=range(min_val[self.var[i]], max_val[self.var[i]])) fig.colorbar(cp) # Add a colorbar to a plot ax.set_title(title) ax.set_xlabel(x_name) @@ -390,6 +406,7 @@ class Plotter: self.__avg_plot() def plot_contour(self): + self.__get_min_max_bar() self.__plot_contour() def ani_plot_contour(self): diff --git a/plotter/main.py b/plotter/main.py index 442747ce66cf0b494ad9a4ffe3cb316e2d13db3f..95c1f0b506a30461160424994512583c497031ad 100755 --- a/plotter/main.py +++ b/plotter/main.py @@ -4,7 +4,7 @@ from pathlib import PurePath import natsort import os -manual_plot=False +manual_plot=True save_result=True def dump(filename, var=[None], mval=[None]): @@ -34,9 +34,9 @@ def ani_plot(filename, out = './', oname = 'fig.gif', var=[None], mval=[None], m Plot.set(args, if_manual_plot=manual_plot, if_save_result=save_result) Plot.ani_plot() -def plot_contour(filename, out = './', oname = [None], var=[None], mval=[None]): +def plot_contour(filename, out = './', oname = [None], var=[None], mval=[None], min_y = None, max_y = None): Plot = Plotter() - args = Args([filename], Plot.plot_contour, var=var, mval=mval, oname=oname, out=out) + args = Args([filename], Plot.plot_contour, var=var, mval=mval, oname=oname, out=out, min_y=min_y, max_y=max_y) Plot.set(args, if_manual_plot=manual_plot, if_save_result=save_result) Plot.plot_contour() diff --git a/setup.py b/setup.py index 1cdbf9a563c21cd2f4049bfcb942154337851688..17ca56eac4d2eebfac1e3aab1c58e8c4d3be6a16 100755 --- a/setup.py +++ b/setup.py @@ -4,11 +4,11 @@ if __name__ == "__main__": setuptools.setup( name='plotter', version="0.2", - # install_requires=[ - # "numpy>=1.23.5", - # "matplotlib >=3.6.2", - # "natsort >=8.2.0", - # "imageio >=2.22.4"], + install_requires=[ + "numpy>=1.23.5", + "matplotlib >=3.6.2", + "natsort >=8.2.0", + "imageio >=2.22.4"], packages=setuptools.find_packages( where='.',