Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: 'AxesSubplot' object is not subscriptable #325

Closed
vredzhepov opened this issue Sep 9, 2021 · 5 comments
Closed

TypeError: 'AxesSubplot' object is not subscriptable #325

vredzhepov opened this issue Sep 9, 2021 · 5 comments

Comments

@vredzhepov
Copy link

vredzhepov commented Sep 9, 2021

`# 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
@bemoody
Copy link
Collaborator

bemoody commented Sep 9, 2021

Yeah, that's strange. That plot command works when running from the command line (using the Tk backend for matplotlib) but fails when running in jupyter.

No idea why that would be, though I know very little about matplotlib or jupyter.

@vredzhepov
Copy link
Author

I've just tried to run the demo from the command line (IPython) and got the same result. Seems the same issue is described here https://stackoverflow.com/questions/52273546/matplotlib-typeerror-axessubplot-object-is-not-subscriptable

@bemoody
Copy link
Collaborator

bemoody commented Sep 9, 2021

Okay, actually I was wrong, it's not the backend. This bug was already fixed (in pull #308) but not yet released. So we need to do that. :)

@vredzhepov
Copy link
Author

You're right I've just tested the demo on the master branch and it works as expected. So the bug presents in the v3.4.0. Are you going to close this issue when the new release will be available?

@vredzhepov
Copy link
Author

Fixed in v3.4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants