Skip to content

Commit 8951b9f

Browse files
committed
Update optional automatic limitation of y-axis range in plot2D()
(now only applies if the specified maximum range is exceeded)
1 parent 5b01f29 commit 8951b9f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

sound_field_analysis/plot.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,11 +486,14 @@ def plot2D(
486486

487487
if lim_y_range and viz_type in ["ETC", "LOGFFT"]:
488488
_Y_MARGIN = 5
489-
_Y_DR = 120 if viz_type == "ETC" else 80
490-
# limit layout range of y-axis based on data
489+
_Y_DR = 110 if viz_type == "ETC" else 70
490+
491+
y_min = _np.min([trace.y.min() for trace in traces])
491492
y_max = _np.max([trace.y.max() for trace in traces])
492-
y_max = _np.ceil((y_max + _Y_MARGIN / 2) / _Y_MARGIN) * _Y_MARGIN
493-
layout.yaxis.range = [y_max - _Y_DR, y_max]
493+
if y_max - y_min > _Y_DR:
494+
# limit layout range of y-axis based on data
495+
y_max = _np.ceil((y_max + _Y_MARGIN / 2) / _Y_MARGIN) * _Y_MARGIN
496+
layout.yaxis.range = [y_max - _Y_DR, y_max]
494497

495498
_showTrace(traces, layout=layout, title=title)
496499

0 commit comments

Comments
 (0)