Skip to content

TypeError: 'AxesSubplot' object is not subscriptable #325

@vredzhepov

Description

@vredzhepov
`# Demo 4 - Read part of a WFDB annotation file into a wfdb.Annotation object, and plot the samples
annotation = wfdb.rdann('sample-data/100', 'atr', sampfrom=100000, sampto=110000)
annotation.fs = 360
wfdb.plot_wfdb(annotation=annotation, time_units='minutes')`

`# Can also read the same file hosted on PhysioNet 
annotation2 = wfdb.rdann('100', 'atr', sampfrom=100000, sampto=110000, pn_dir='mitdb')`

TypeError: 'AxesSubplot' object is not subscriptable
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/tmp/ipykernel_226822/286435021.py in <module>
      2 annotation = wfdb.rdann('sample-data/100', 'atr', sampfrom=100000, sampto=110000)
      3 annotation.fs = 360
----> 4 wfdb.plot_wfdb(annotation=annotation, time_units='minutes')
      5 
      6 # Can also read the same file hosted on PhysioNet

.venv/lib/python3.8/site-packages/wfdb/plot/plot.py in plot_wfdb(record, annotation, plot_sym, time_units, title, sig_style, ann_style, ecg_grids, figsize, return_fig)
    640                                                               plot_sym=plot_sym)
    641 
--> 642     return plot_items(signal=signal, ann_samp=ann_samp, ann_sym=ann_sym, fs=fs,
    643                       time_units=time_units, ylabel=ylabel,
    644                       title=(title or record_name),

.venv/lib/python3.8/site-packages/wfdb/plot/plot.py in plot_items(signal, ann_samp, ann_sym, fs, time_units, sig_name, sig_units, xlabel, ylabel, title, sig_style, ann_style, ecg_grids, figsize, sharex, sharey, return_fig, return_fig_axes)
    120 
    121     if ann_samp is not None:
--> 122         plot_annotation(ann_samp, n_annot, ann_sym, signal, n_sig, fs,
    123                         time_units, ann_style, axes)
    124 

.venv/lib/python3.8/site-packages/wfdb/plot/plot.py in plot_annotation(ann_samp, n_annot, ann_sym, signal, n_sig, fs, time_units, ann_style, axes)
    351                                 'the "rdann" function?')
    352 
--> 353             axes[ch].plot(ann_samp[ch] / downsample_factor, y, ann_style[ch])
    354 
    355             # Plot the annotation symbols if any

TypeError: 'AxesSubplot' object is not subscriptable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions