To plot simulation results (possibly along with experimental data), different methods are viable:
In the following, we will explain the last of these three methods.
BornAgain’s MatPlotLib-based plotting functions are available directly from
the bornagain Python package:
import bornagain as ba
The same import also provides MatPlotLib’s pyplot module as ba.plt, so a
typical BornAgain plotting script needs no second import.
The main functions are
ba.plot_datafield(result, **plotargs) # plot one Datafield
ba.plot_array(array, frame, **plotargs) # array with physical axes
ba.plot_multicurve(results, **plotargs) # several 1D Datafields
ba.plot_specular_curves(curves, ...) # curves with error bars
ba.plot_material_profile(profiles, z_unit, ...) # one or more SLD profiles
ba.plot2d_to_grid(results, ncol, **plotargs) # 2D Datafields in a grid
ba.plot2d_to_row(results, **plotargs) # 2D Datafields in a row
where result is a Datafield as returned by simulation.simulate(), array is
a NumPy array, frame supplies its physical axes, and results is a list of
Datafields.
To finalize a plot, call one of
ba.plt.show() # display the plot in a MatPlotLib window
ba.export(**plotargs) # write the plot to an image file
See
$...$ typeset with LaTeXThe functions remain organized in the importable implementation module
ba_plot.
User scripts should call them through ba, so that their imports do not
depend on the package’s internal module layout.
If our plot functions are not versatile enough for your needs, then copy, rename, and modify them.