diff --git a/specparam/core/reports.py b/specparam/core/reports.py index 3ccf5548..c1bd8341 100644 --- a/specparam/core/reports.py +++ b/specparam/core/reports.py @@ -179,12 +179,12 @@ def save_event_report(event_model, file_name, file_path=None, add_settings=True) has_knee = 'knee' in event_model.event_time_results.keys() # Initialize figure, defining number of axes based on model + what is to be plotted - n_rows = 1 + (4 if has_knee else 3) + (n_bands * 4) + 2 + (1 if add_settings else 0) + n_rows = 1 + (4 if has_knee else 3) + (n_bands * 5) + 2 + (1 if add_settings else 0) height_ratios = [2.75] + [1] * (3 if has_knee else 2) + \ - [0.25, 1, 1, 1] * n_bands + [0.25] + [1, 1] + ([1.5] if add_settings else []) + [0.25, 1, 1, 1, 1] * n_bands + [0.25] + [1, 1] + ([1.5] if add_settings else []) _, axes = plt.subplots(n_rows, 1, gridspec_kw={'hspace' : 0.1, 'height_ratios' : height_ratios}, - figsize=(REPORT_FIGSIZE[0], REPORT_FIGSIZE[1] + 6)) + figsize=(REPORT_FIGSIZE[0], REPORT_FIGSIZE[1] + 7)) # First / top: text results plot_text(gen_event_results_str(event_model), 0.5, 0.7, ax=axes[0]) diff --git a/specparam/plts/event.py b/specparam/plts/event.py index 756ed948..1f7ec680 100644 --- a/specparam/plts/event.py +++ b/specparam/plts/event.py @@ -8,6 +8,7 @@ from itertools import cycle from specparam.data.utils import get_periodic_labels, get_band_labels +from specparam.utils.data import compute_presence from specparam.plts.utils import savefig from specparam.plts.templates import plot_param_over_time_yshade from specparam.plts.settings import PARAM_COLORS @@ -45,13 +46,13 @@ def plot_event_model(event_model, **plot_kwargs): n_bands = len(pe_labels['cf']) has_knee = 'knee' in event_model.event_time_results.keys() - height_ratios = [1] * (3 if has_knee else 2) + [0.25, 1, 1, 1] * n_bands + [0.25] + [1, 1] + height_ratios = [1] * (3 if has_knee else 2) + [0.25, 1, 1, 1, 1] * n_bands + [0.25] + [1, 1] axes = plot_kwargs.pop('axes', None) if axes is None: - _, axes = plt.subplots((4 if has_knee else 3) + (n_bands * 4) + 2, 1, + _, axes = plt.subplots((4 if has_knee else 3) + (n_bands * 5) + 2, 1, gridspec_kw={'hspace' : 0.1, 'height_ratios' : height_ratios}, - figsize=plot_kwargs.pop('figsize', [10, 4 + 4 * n_bands])) + figsize=plot_kwargs.pop('figsize', [10, 4 + 5 * n_bands])) axes = cycle(axes) xlim = [0, event_model.n_time_windows - 1] @@ -74,6 +75,10 @@ def plot_event_model(event_model, **plot_kwargs): label=plabel.upper(), drop_xticks=True, add_xlabel=False, xlim=xlim, title='Periodic Parameters - ' + band_labels[band_ind] if plabel == 'cf' else None, color=PARAM_COLORS[plabel], ax=next(axes)) + plot_param_over_time_yshade(\ + None, compute_presence(event_model.event_time_results[pe_labels[plabel][band_ind]]), + label='Presence', drop_xticks=True, add_xlabel=False, xlim=xlim, + color=PARAM_COLORS['presence'], ax=next(axes)) next(axes).axis('off') # 03: goodness of fit diff --git a/specparam/plts/settings.py b/specparam/plts/settings.py index 0473a48e..263a5bee 100644 --- a/specparam/plts/settings.py +++ b/specparam/plts/settings.py @@ -30,6 +30,7 @@ 'cf' : '#acc918', 'pw' : '#28a103', 'bw' : '#0fd197', + 'presence' : '#095407', 'error' : '#940000', 'r_squared' : '#ab7171', }