SleepECG - remove the annotations part in my hypnogram plot

Hi, i´m using the SleepECG library to plot my sleepstages for a single record. When I do, automatically an annotated subplot is generated in my hypnogram plot. Every usual attempt to remove it in my code has failed (I tried to make sure that annotated sleep stages are empty in my record). How could I remove this subplot as I do not have any annotations atm.

Thank you!

I’m not sure I understand. Can you show your code that produces the plots?

1 Like

Hi, this this the code snippets that produces my plots:

def classify_and_plot_sleep_stages(record: SleepRecord, **kwargs) -> plt.Figure: 
    classifier_name = kwargs.get('classifier_name', DEFAULT_CLASSIFIER_NAME)
    classifier_source = kwargs.get('classifier_source', DEFAULT_CLASSIFIER_SOURCE)
    return_mode = kwargs.get('return_mode', DEFAULT_RETURN_MODE)
    stages_mode = kwargs.get('stages_mode', 'wake-rem-n1-n2-n3')
    merge_annotations = kwargs.get('merge_annotations', DEFAULT_MERGE_ANNOTATIONS)
    show_bpm = kwargs.get('show_bpm', DEFAULT_SHOW_BPM)
    save_to = kwargs.get('save_to', DEFAULT_SAVE_TO)

    clf = load_classifier(classifier_name, classifier_source)
    stages_pred = stage(clf, record, return_mode=return_mode)

    hypnogram_fig = plot_hypnogram(
        record, 
        stages_pred, 
        stages_mode=stages_mode, 
        merge_annotations=merge_annotations, 
        show_bpm=show_bpm,
    )


    if save_to is not None: 
        save_sleep_hypnogram(hypnogram_fig, save_to)

    plt.show()

    return hypnogram_fig

My issue is that a completely empty “annotated” subplot is generated. Ideally I would remove this subplot.

Can you verify that record.sleep_stages is indeed None?