Skip to content
Snippets Groups Projects
Commit a97cc038 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

plot_utils: title now as kwargs

parent 9bfd4263
No related branches found
No related tags found
No related merge requests found
...@@ -84,7 +84,7 @@ def get_axes_labels(result, units): ...@@ -84,7 +84,7 @@ def get_axes_labels(result, units):
return labels return labels
def plot_array(array, title=None, axes_limits=None, **kwargs): def plot_array(array, axes_limits=None, **kwargs):
""" """
Plots numpy array as a colormap in log scale. Plots numpy array as a colormap in log scale.
""" """
...@@ -101,6 +101,8 @@ def plot_array(array, title=None, axes_limits=None, **kwargs): ...@@ -101,6 +101,8 @@ def plot_array(array, title=None, axes_limits=None, **kwargs):
ylabel = kwargs.pop('ylabel', None) ylabel = kwargs.pop('ylabel', None)
zlabel = kwargs.pop('zlabel', "Intensity") zlabel = kwargs.pop('zlabel', "Intensity")
title = kwargs.pop('title', None)
im = plt.imshow(array, norm=norm, extent=axes_limits, **kwargs) im = plt.imshow(array, norm=norm, extent=axes_limits, **kwargs)
cb = plt.colorbar(im, pad=0.025) cb = plt.colorbar(im, pad=0.025)
...@@ -115,7 +117,7 @@ def plot_array(array, title=None, axes_limits=None, **kwargs): ...@@ -115,7 +117,7 @@ def plot_array(array, title=None, axes_limits=None, **kwargs):
plt.title(title) plt.title(title)
def plot_histogram(hist, title=None, **kwargs): def plot_histogram(hist, **kwargs):
""" """
Plots intensity data as color map Plots intensity data as color map
:param intensity: Histogram2D object obtained from GISASSimulation :param intensity: Histogram2D object obtained from GISASSimulation
...@@ -135,10 +137,12 @@ def plot_histogram(hist, title=None, **kwargs): ...@@ -135,10 +137,12 @@ def plot_histogram(hist, title=None, **kwargs):
hist.getYmax() hist.getYmax()
] ]
title = kwargs.pop('title', None)
plot_array(hist.array(), title=title, axes_limits=axes_limits, **kwargs) plot_array(hist.array(), title=title, axes_limits=axes_limits, **kwargs)
def plot_colormap(result, units=ba.Axes.DEFAULT, title=None, **kwargs): def plot_colormap(result, units=ba.Axes.DEFAULT, **kwargs):
""" """
Plots intensity data as color map Plots intensity data as color map
:param result: SimulationResult from GISAS/OffSpecSimulation :param result: SimulationResult from GISAS/OffSpecSimulation
...@@ -154,14 +158,13 @@ def plot_colormap(result, units=ba.Axes.DEFAULT, title=None, **kwargs): ...@@ -154,14 +158,13 @@ def plot_colormap(result, units=ba.Axes.DEFAULT, title=None, **kwargs):
if not 'ylabel' in kwargs: if not 'ylabel' in kwargs:
kwargs['ylabel'] = axes_labels[1] kwargs['ylabel'] = axes_labels[1]
plot_array(result.array(), title=title, axes_limits=axes_limits, **kwargs) plot_array(result.array(), axes_limits=axes_limits, **kwargs)
def plot_specular_simulation_result(result, def plot_specular_simulation_result(result,
ymin=None, ymin=None,
ymax=None, ymax=None,
units=ba.Axes.DEFAULT, units=ba.Axes.DEFAULT,
title=None,
**kwargs): **kwargs):
""" """
Plots intensity data for specular simulation result Plots intensity data for specular simulation result
...@@ -179,6 +182,7 @@ def plot_specular_simulation_result(result, ...@@ -179,6 +182,7 @@ def plot_specular_simulation_result(result,
xlabel = kwargs.pop('xlabel', get_axes_labels(result, units)[0]) xlabel = kwargs.pop('xlabel', get_axes_labels(result, units)[0])
ylabel = kwargs.pop('ylabel', "Intensity") ylabel = kwargs.pop('ylabel', "Intensity")
title = kwargs.pop('title', None)
plt.semilogy(x_axis, intensity, **kwargs) plt.semilogy(x_axis, intensity, **kwargs)
...@@ -196,7 +200,6 @@ def plot_specular_simulation_result(result, ...@@ -196,7 +200,6 @@ def plot_specular_simulation_result(result,
def plot_simulation_result(result, def plot_simulation_result(result,
units=ba.Axes.DEFAULT, units=ba.Axes.DEFAULT,
postpone_show=False, postpone_show=False,
title=None,
**kwargs): **kwargs):
""" """
Draws simulation result and (optionally) shows the plot. Draws simulation result and (optionally) shows the plot.
...@@ -209,7 +212,7 @@ def plot_simulation_result(result, ...@@ -209,7 +212,7 @@ def plot_simulation_result(result,
if len(result.array().shape) == 1: # 1D data, specular simulation assumed if len(result.array().shape) == 1: # 1D data, specular simulation assumed
plot_specular_simulation_result(result, units, **kwargs) plot_specular_simulation_result(result, units, **kwargs)
else: else:
plot_colormap(result, units, title=title, **kwargs) plot_colormap(result, units, **kwargs)
plt.tight_layout() plt.tight_layout()
if not (postpone_show): if not (postpone_show):
plt.show() plt.show()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment