Skip to content

Commit 01b4a73

Browse files
committed
New isolines option to set isolines values
1 parent df7313d commit 01b4a73

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

stagpy/config.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ def _index_collection(arg):
3232
return [_actual_index(item) for item in arg.split(',') if item]
3333

3434

35+
def _float_list(arg):
36+
"""Build a tuple of floats from a command line input."""
37+
return tuple(float(val) for val in arg.split(',') if val)
38+
39+
3540
HOME_DIR = pathlib.Path.home()
3641
CONFIG_DIR = HOME_DIR / '.config' / 'stagpy'
3742
CONFIG_FILE = CONFIG_DIR / 'config.toml'
@@ -72,6 +77,8 @@ def _index_collection(arg):
7277
('vmax', Conf(None, True, None, {'type': float},
7378
False, 'maximal value on plot')),
7479
('cminmax', switch_opt(False, 'C', 'constant min max across plots')),
80+
('isolines', Conf(None, True, None, {'type': _float_list},
81+
False, 'arbitrary isoline value, comma separated')),
7582
('mplstyle', Conf('stagpy-paper', True, None,
7683
{'nargs': '?', 'const': '', 'type': str},
7784
True, 'matplotlib style')),

stagpy/field.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ def plot_iso(axis, step, var, **extra):
257257
extra_opts['colors'] = conf.field.isocolors.split(',')
258258
elif 'colors' not in extra:
259259
extra_opts['cmap'] = conf.field.cmap.get(var)
260+
if conf.plot.isolines:
261+
extra_opts['levels'] = sorted(conf.plot.isolines)
260262
extra_opts.update(extra)
261263
axis.contour(xmesh, ymesh, fld, **extra_opts)
262264

0 commit comments

Comments
 (0)