File: export.md

package info (click to toggle)
bornagain 23.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 103,948 kB
  • sloc: cpp: 423,131; python: 40,997; javascript: 11,167; awk: 630; sh: 318; ruby: 173; xml: 130; makefile: 51; ansic: 24
file content (46 lines) | stat: -rw-r--r-- 1,114 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
+++
title = "Export"
weight = 70
+++

# Export plot to file

### Interactively

To create image files interactively,
run a script that contains the usual
```python
bp.plt.show()
```
then click the "diskette" icon in the MatPlotLib window.

### Programmatically

To create image files programmatically,
replace the Python statement
```python
bp.plt.show()
```
by one of
```python
bp.export(**plotargs)
```
and use one of the three parameterization mechanisms
described in the [Configuration](config) 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:
```python
import matplotlib.pyplot as plt
fig = 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.