Repository navigation
Closed
Description
`# 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
Labels
No labels
Activity
bemoody commentedon 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 commentedon Sep 9, 2021
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 commentedon 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 commentedon Sep 9, 2021
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 commentedon Sep 15, 2021
Fixed in v3.4.1