Skip to content

Commit cd74a17

Browse files
authored
Colorbar kwargs default (#195)
* add colorbar label defaults if these kwargs are not submitted to level() and amplitude() -use handling from PR191 - plot amplitude() no colorbar label as default - plot level() 'level / dB' as default - use extend = 'both' as already suggested by PR191
1 parent da22502 commit cd74a17

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

sfs/plot2d.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def _plotting_plane(p, grid):
230230

231231
def amplitude(p, grid, *, xnorm=None, cmap='coolwarm_clip',
232232
vmin=-2.0, vmax=2.0, xlabel=None, ylabel=None,
233-
colorbar=True, colorbar_kwargs={}, ax=None, **kwargs):
233+
colorbar=True, colorbar_kwargs=None, ax=None, **kwargs):
234234
"""Two-dimensional plot of sound field (real part).
235235
236236
Parameters
@@ -319,12 +319,14 @@ def amplitude(p, grid, *, xnorm=None, cmap='coolwarm_clip',
319319
ax.set_xlabel(xlabel)
320320
ax.set_ylabel(ylabel)
321321
if colorbar:
322+
if colorbar_kwargs is None:
323+
colorbar_kwargs = dict(extend='both')
322324
add_colorbar(im, **colorbar_kwargs)
323325
return im
324326

325327

326328
def level(p, grid, *, xnorm=None, power=False, cmap=None, vmax=3, vmin=-50,
327-
**kwargs):
329+
colorbar_kwargs=None, **kwargs):
328330
"""Two-dimensional plot of level (dB) of sound field.
329331
330332
Takes the same parameters as `sfs.plot2d.amplitude()`.
@@ -339,8 +341,11 @@ def level(p, grid, *, xnorm=None, power=False, cmap=None, vmax=3, vmin=-50,
339341
if xnorm is not None:
340342
p = _util.normalize(p, grid, xnorm)
341343
L = _util.db(p, power=power)
344+
if colorbar_kwargs is None:
345+
colorbar_kwargs = dict(extend='both', label='level / dB')
342346
return amplitude(L, grid=grid, xnorm=None, cmap=cmap,
343-
vmax=vmax, vmin=vmin, **kwargs)
347+
vmax=vmax, vmin=vmin,
348+
colorbar_kwargs=colorbar_kwargs, **kwargs)
344349

345350

346351
def level_contour(p, grid, *, xnorm=None, power=False,

0 commit comments

Comments
 (0)