From 641961a078c30112b95a4e97485f582e5ef2c917 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Tue, 8 Dec 2020 22:39:38 +0100 Subject: [PATCH] plot_utils: pass intensity min/max as kwargs --- .../LargeParticlesFormFactor.py | 4 +-- .../AccessingSimulationResults.py | 8 +++--- Wrap/Python/plot_utils.py | 25 +++++-------------- 3 files changed, 11 insertions(+), 26 deletions(-) diff --git a/Examples/Python/sim02_Complexes/LargeParticlesFormFactor.py b/Examples/Python/sim02_Complexes/LargeParticlesFormFactor.py index 0bb087fdd4f..2f2e28ab0a9 100644 --- a/Examples/Python/sim02_Complexes/LargeParticlesFormFactor.py +++ b/Examples/Python/sim02_Complexes/LargeParticlesFormFactor.py @@ -108,8 +108,8 @@ def simulate_and_plot(): zmin = condition['zmin'] zmax = condition['zmax'] ba.plot_colormap(result, - zmin=zmin, - zmax=zmax, + intensity_min=zmin, + intensity_max=zmax, cmap='jet', aspect='auto') diff --git a/Examples/Python/sim31_Parameterization/AccessingSimulationResults.py b/Examples/Python/sim31_Parameterization/AccessingSimulationResults.py index b1e8ad350cd..4f77425a768 100644 --- a/Examples/Python/sim31_Parameterization/AccessingSimulationResults.py +++ b/Examples/Python/sim31_Parameterization/AccessingSimulationResults.py @@ -71,15 +71,13 @@ def get_noisy_image(hist): return result -def plot_histogram(hist, zmin=None, zmax=None): +def plot_histogram(hist, **kwargs): ba.plot_histogram(hist, xlabel=r'$\varphi_f ^{\circ}$', ylabel=r'$\alpha_f ^{\circ}$', zlabel="", - zmin=zmin, - zmax=zmax, cmap='jet', - aspect='auto') + aspect='auto', **kwargs) def get_relative_difference(hist): @@ -140,7 +138,7 @@ def plot(hist): plt.subplot(2, 2, 3) reldiff = get_relative_difference(hist) - plot_histogram(reldiff, zmin=1e-03, zmax=10) + plot_histogram(reldiff, intensity_min=1e-03, intensity_max=10) plt.title("Relative difference") plt.subplot(2, 2, 4) diff --git a/Wrap/Python/plot_utils.py b/Wrap/Python/plot_utils.py index 662eb550624..899fd59db6e 100644 --- a/Wrap/Python/plot_utils.py +++ b/Wrap/Python/plot_utils.py @@ -85,8 +85,6 @@ def get_axes_labels(result, units): def plot_array(array, - zmin=None, - zmax=None, xlabel=None, ylabel=None, zlabel=None, @@ -99,8 +97,8 @@ def plot_array(array, zlabel = "Intensity" if zlabel is None else zlabel - zmax = np.amax(array) if zmax is None else zmax - zmin = 1e-6*zmax if zmin is None else zmin + zmax = kwargs.pop('intensity_max', np.amax(array)) + zmin = kwargs.pop('intensity_min', 1e-6*zmax) if zmin == zmax == 0.0: norm = colors.Normalize(0, 1) @@ -124,8 +122,6 @@ def plot_array(array, def plot_histogram(hist, - zmin=None, - zmax=None, xlabel=None, ylabel=None, zlabel=None, @@ -152,8 +148,6 @@ def plot_histogram(hist, ] plot_array(hist.array(), - zmin=zmin, - zmax=zmax, xlabel=xlabel, ylabel=ylabel, zlabel=zlabel, @@ -163,8 +157,6 @@ def plot_histogram(hist, def plot_colormap(result, - zmin=None, - zmax=None, units=ba.Axes.DEFAULT, xlabel=None, ylabel=None, @@ -184,8 +176,6 @@ def plot_colormap(result, ylabel = axes_labels[1] if ylabel is None else ylabel plot_array(result.array(), - zmin=zmin, - zmax=zmax, xlabel=xlabel, ylabel=ylabel, zlabel=zlabel, @@ -212,8 +202,9 @@ def plot_specular_simulation_result(result, intensity = result.array(units) x_axis = result.axis(units) - ymax = np.amax(intensity)*2.0 if ymax is None else ymax - ymin = max(np.amin(intensity)*0.5, 1e-18*ymax) if ymin is None else ymin + + ymax = kwargs.pop('intensity_max', np.amax(np.amax(intensity)*2)) + ymin = kwargs.pop('intensity_min', max(np.amin(intensity)*0.5, 1e-18*ymax)) xlabel = get_axes_labels(result, units)[0] if xlabel is None else xlabel ylabel = "Intensity" if ylabel is None else ylabel @@ -233,8 +224,6 @@ def plot_specular_simulation_result(result, def plot_simulation_result(result, - intensity_min=None, - intensity_max=None, units=ba.Axes.DEFAULT, xlabel=None, ylabel=None, @@ -250,12 +239,10 @@ def plot_simulation_result(result, :param postpone_show: postpone showing the plot for later tuning (False by default) """ if len(result.array().shape) == 1: # 1D data, specular simulation assumed - plot_specular_simulation_result(result, intensity_min, intensity_max, + plot_specular_simulation_result(result, units, **kwargs) else: plot_colormap(result, - intensity_min, - intensity_max, units, xlabel, ylabel, -- GitLab