Export plot to file

Interactively

To create image files interactively, run a BornAgain script that contains

import bornagain as ba

ba.plt.show()

then click the “diskette” icon in the MatPlotLib window.

Programmatically

To create image files programmatically, replace the Python statement

ba.plt.show()

by one of

ba.export(**plotargs)

and use one of the three parameterization mechanisms described in the Configuration page to pass a keyword argument figfile=<filename>. The image format is deduced from the extension of the filename.

Image formats

Which image formats are supported depends on the local MatPlotLib installation. To find out, either click on the export (“diskette”) icon in an interactive MatPlotLib widget, or run the following Python lines:

import bornagain as ba

fig = ba.plt.figure()
print(fig.canvas.get_supported_filetypes())

For plots generated by BornAgain, prefer a vector image format, with extension .svg, .eps, .ps, or .pdf. Maybe .emf is still useful under Windows.