Coverage for pySDC / projects / RayleighBenard / analysis_scripts / plotting_utils.py: 100%
6 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-02-12 11:13 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-02-12 11:13 +0000
1from functools import partial
2import warnings
3import os
5from pySDC.helpers.plot_helper import figsize_by_journal, setup_mpl
7setup_mpl()
9figsize = partial(figsize_by_journal, journal='Nature_CS')
12def get_plotting_style(config): # pragma: no cover
14 args = {'color': None, 'ls': None, 'marker': None, 'markersize': 6, 'label': None}
16 config_no_Ra = config[: config.index('Ra')]
18 if config_no_Ra == 'RBC3DG4R4SDC22':
19 args['color'] = 'tab:brown'
20 args['ls'] = '-'
21 args['marker'] = '3'
22 args['label'] = 'SDC22'
23 elif config_no_Ra == 'RBC3DG4R4SDC23':
24 args['color'] = 'tab:blue'
25 args['ls'] = '-'
26 args['marker'] = 'o'
27 args['label'] = 'SDC23'
28 elif config_no_Ra == 'RBC3DG4R4SDC34':
29 args['color'] = 'tab:orange'
30 args['ls'] = '-'
31 args['marker'] = '<'
32 args['label'] = 'SDC34'
33 elif config_no_Ra == 'RBC3DG4R4SDC44':
34 args['color'] = 'tab:green'
35 args['ls'] = '-'
36 args['marker'] = 'x'
37 args['label'] = 'SDC44'
38 elif config_no_Ra == 'RBC3DG4R4Euler':
39 args['color'] = 'tab:purple'
40 args['ls'] = '--'
41 args['marker'] = '.'
42 args['label'] = 'RK111'
43 elif config_no_Ra == 'RBC3DG4R4RK':
44 args['color'] = 'tab:red'
45 args['ls'] = '--'
46 args['marker'] = '>'
47 args['label'] = 'RK443'
48 else:
49 warnings.warn(f'No plotting style for {config=!r}')
51 return args
54def savefig(fig, name, format='pdf', base_path='./plots', **kwargs): # pragma: no cover
55 os.makedirs(base_path, exist_ok=True)
57 path = f'{base_path}/{name}.{format}'
58 fig.savefig(path, bbox_inches='tight', **kwargs)
59 print(f'Saved figure {path!r}')