Skip to content

Commit fd2e03f

Browse files
committed
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 8d519b2 commit fd2e03f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

sfs/plot2d.py

Lines changed: 8 additions & 5 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,13 +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-
colorbar_kwargs.setdefault('label', 'relative pressure')
322+
if colorbar_kwargs is None:
323+
colorbar_kwargs = dict(extend='both')
323324
add_colorbar(im, **colorbar_kwargs)
324325
return im
325326

326327

327328
def level(p, grid, *, xnorm=None, power=False, cmap=None, vmax=3, vmin=-50,
328-
**kwargs):
329+
colorbar_kwargs=None, **kwargs):
329330
"""Two-dimensional plot of level (dB) of sound field.
330331
331332
Takes the same parameters as `sfs.plot2d.amplitude()`.
@@ -340,9 +341,11 @@ def level(p, grid, *, xnorm=None, power=False, cmap=None, vmax=3, vmin=-50,
340341
if xnorm is not None:
341342
p = _util.normalize(p, grid, xnorm)
342343
L = _util.db(p, power=power)
343-
kwargs.setdefault('colorbar_kwargs', {'label': 'level / dB'})
344+
if colorbar_kwargs is None:
345+
colorbar_kwargs = dict(extend='both', label='level / dB')
344346
return amplitude(L, grid=grid, xnorm=None, cmap=cmap,
345-
vmax=vmax, vmin=vmin, **kwargs)
347+
vmax=vmax, vmin=vmin,
348+
colorbar_kwargs=colorbar_kwargs, **kwargs)
346349

347350

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

0 commit comments

Comments
 (0)