diff --git a/auto/Examples/scatter2d/AxesInDifferentUnits.py b/auto/Examples/scatter2d/AxesInDifferentUnits.py index 97ba2984d94ebcab02b0af3bbf9602669d3af7d2..b33adec922993e2fc988c08a779e58a3bfb75c06 100755 --- a/auto/Examples/scatter2d/AxesInDifferentUnits.py +++ b/auto/Examples/scatter2d/AxesInDifferentUnits.py @@ -27,52 +27,34 @@ def get_simulation(sample): return simulation -def plot(result): +def transformed_plot(i, result, title): """ Plots simulation results for different detectors. """ - # set plotting parameters - rcParams['image.aspect'] = 'auto' - - plt.figure(figsize=(10, 10)) - - plt.subplot(2, 2, 1) - # default units for rectangular detector are millimeters + plt.subplot(2, 2, i) bp.plot_simres(result, - xlabel=r'$x \;({\rm mm})$', - ylabel=r'$y \;({\rm mm})$', + # xlabel=r'$x \;({\rm mm})$', + # ylabel=r'$y \;({\rm mm})$', zlabel=None, with_cb=False) - plt.title("Default: real-space detector coordinates", loc='left') + plt.title(title, loc='left') - plt.subplot(2, 2, 2) - bp.plot_simres(result, - # units=ba.Coords_NBINS, - xlabel=r'$X_{\rm bin}$', - ylabel=r'$Y_{\rm bin}$', - zlabel=None, - with_cb=False) - plt.title("Bin indices", loc='left') - plt.subplot(2, 2, 3) - bp.plot_simres(result, - # units=ba.Coords_DEGREES, - xlabel=r'$\varphi_{\rm f} \;(^{\circ})$', - ylabel=r'$\alpha_{\rm f} \;(^{\circ})$', - zlabel=None, - with_cb=False) - plt.title("Deflection angles", loc='left') +if __name__ == '__main__': + simulation = get_simulation(get_sample()) + result = simulation.simulate() - plt.subplot(2, 2, 4) - bp.plot_simres(result, - # units=ba.Coords_QSPACE, - xlabel=r'$Q_{y} \;(1/{\rm nm})$', - ylabel=r'$Q_{z} \;(1/{\rm nm})$', - zlabel=None, - with_cb=False) - plt.title("Q space", loc='left') + # setup plot + rcParams['image.aspect'] = 'auto' + plt.figure(figsize=(10, 10)) + + transformed_plot(1, result, "Default: real-space detector coordinates") + transformed_plot(2, result, "Bin indices") + transformed_plot(3, result, "Deflection angles") + transformed_plot(4, result, "Q space") + # finish plot plt.subplots_adjust( left=0.07, right=0.97, @@ -81,11 +63,4 @@ def plot(result): hspace=0.35, wspace=0., ) - - -if __name__ == '__main__': - simulation = get_simulation(get_sample()) - result = simulation.simulate() - - plot(result) bp.show_or_export() diff --git a/auto/MiniExamples/scatter2d/AxesInDifferentUnits.py b/auto/MiniExamples/scatter2d/AxesInDifferentUnits.py index a9c9a64ab31f45cf621eefd395501019eecd9541..40bcc347b2b66df4f0af8f09fda78dcefc6ad925 100755 --- a/auto/MiniExamples/scatter2d/AxesInDifferentUnits.py +++ b/auto/MiniExamples/scatter2d/AxesInDifferentUnits.py @@ -27,52 +27,34 @@ def get_simulation(sample): return simulation -def plot(result): +def transformed_plot(i, result, title): """ Plots simulation results for different detectors. """ - # set plotting parameters - rcParams['image.aspect'] = 'auto' - - plt.figure(figsize=(10, 10)) - - plt.subplot(2, 2, 1) - # default units for rectangular detector are millimeters + plt.subplot(2, 2, i) bp.plot_simres(result, - xlabel=r'$x \;({\rm mm})$', - ylabel=r'$y \;({\rm mm})$', + # xlabel=r'$x \;({\rm mm})$', + # ylabel=r'$y \;({\rm mm})$', zlabel=None, with_cb=False) - plt.title("Default: real-space detector coordinates", loc='left') + plt.title(title, loc='left') - plt.subplot(2, 2, 2) - bp.plot_simres(result, - # units=ba.Coords_NBINS, - xlabel=r'$X_{\rm bin}$', - ylabel=r'$Y_{\rm bin}$', - zlabel=None, - with_cb=False) - plt.title("Bin indices", loc='left') - plt.subplot(2, 2, 3) - bp.plot_simres(result, - # units=ba.Coords_DEGREES, - xlabel=r'$\varphi_{\rm f} \;(^{\circ})$', - ylabel=r'$\alpha_{\rm f} \;(^{\circ})$', - zlabel=None, - with_cb=False) - plt.title("Deflection angles", loc='left') +if __name__ == '__main__': + simulation = get_simulation(get_sample()) + result = simulation.simulate() - plt.subplot(2, 2, 4) - bp.plot_simres(result, - # units=ba.Coords_QSPACE, - xlabel=r'$Q_{y} \;(1/{\rm nm})$', - ylabel=r'$Q_{z} \;(1/{\rm nm})$', - zlabel=None, - with_cb=False) - plt.title("Q space", loc='left') + # setup plot + rcParams['image.aspect'] = 'auto' + plt.figure(figsize=(10, 10)) + + transformed_plot(1, result, "Default: real-space detector coordinates") + transformed_plot(2, result, "Bin indices") + transformed_plot(3, result, "Deflection angles") + transformed_plot(4, result, "Q space") + # finish plot plt.subplots_adjust( left=0.07, right=0.97, @@ -81,11 +63,4 @@ def plot(result): hspace=0.35, wspace=0., ) - - -if __name__ == '__main__': - simulation = get_simulation(get_sample()) - result = simulation.simulate() - - plot(result) bp.show_or_export() diff --git a/rawEx/scatter2d/AxesInDifferentUnits.py b/rawEx/scatter2d/AxesInDifferentUnits.py index c8f1f870d9346cdaf9c899c8c148148545170f05..9edfc6fb202be158b162b52ba86f680e0cd525bf 100755 --- a/rawEx/scatter2d/AxesInDifferentUnits.py +++ b/rawEx/scatter2d/AxesInDifferentUnits.py @@ -27,52 +27,34 @@ def get_simulation(sample): return simulation -def plot(result): +def transformed_plot(i, result, title): """ Plots simulation results for different detectors. """ - # set plotting parameters - rcParams['image.aspect'] = 'auto' - - plt.figure(figsize=(10, 10)) - - plt.subplot(2, 2, 1) - # default units for rectangular detector are millimeters + plt.subplot(2, 2, i) bp.plot_simres(result, - xlabel=r'$x \;({\rm mm})$', - ylabel=r'$y \;({\rm mm})$', + # xlabel=r'$x \;({\rm mm})$', + # ylabel=r'$y \;({\rm mm})$', zlabel=None, with_cb=False) - plt.title("Default: real-space detector coordinates", loc='left') + plt.title(title, loc='left') - plt.subplot(2, 2, 2) - bp.plot_simres(result, - # units=ba.Coords_NBINS, - xlabel=r'$X_{\rm bin}$', - ylabel=r'$Y_{\rm bin}$', - zlabel=None, - with_cb=False) - plt.title("Bin indices", loc='left') - plt.subplot(2, 2, 3) - bp.plot_simres(result, - # units=ba.Coords_DEGREES, - xlabel=r'$\varphi_{\rm f} \;(^{\circ})$', - ylabel=r'$\alpha_{\rm f} \;(^{\circ})$', - zlabel=None, - with_cb=False) - plt.title("Deflection angles", loc='left') +if __name__ == '__main__': + simulation = get_simulation(get_sample()) + result = simulation.simulate() - plt.subplot(2, 2, 4) - bp.plot_simres(result, - # units=ba.Coords_QSPACE, - xlabel=r'$Q_{y} \;(1/{\rm nm})$', - ylabel=r'$Q_{z} \;(1/{\rm nm})$', - zlabel=None, - with_cb=False) - plt.title("Q space", loc='left') + # setup plot + rcParams['image.aspect'] = 'auto' + plt.figure(figsize=(10, 10)) + + transformed_plot(1, result, "Default: real-space detector coordinates") + transformed_plot(2, result, "Bin indices") + transformed_plot(3, result, "Deflection angles") + transformed_plot(4, result, "Q space") + # finish plot plt.subplots_adjust( left=0.07, right=0.97, @@ -81,11 +63,4 @@ def plot(result): hspace=0.35, wspace=0., ) - - -if __name__ == '__main__': - simulation = get_simulation(get_sample()) - result = simulation.simulate() - - plot(result) bp.show_or_export()