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

"'AxesSubplot' object is not subscriptable" in plot.py:283 #315

Closed
jensmetzner opened this issue Aug 3, 2021 · 2 comments
Closed

"'AxesSubplot' object is not subscriptable" in plot.py:283 #315

jensmetzner opened this issue Aug 3, 2021 · 2 comments

Comments

@jensmetzner
Copy link

I'm trying to run the # Demo 6 example from demo.ipynb:

from IPython.display import display
import wfdb

record = wfdb.rdrecord('p000878/3269321_0001')
display(record.__dict__)
wfdb.plot_wfdb(record=record, title='Record p000878/3269321_0001')

But I receive the following output/error:

{'record_name': '3269321_0001',
 'n_sig': 1,
 'fs': 125,
 'counter_freq': None,
 'base_counter': None,
 'sig_len': 2000,
 'base_time': datetime.time(16, 57, 39),
 'base_date': None,
 'comments': [],
 'sig_name': ['PLETH'],
 'p_signal': array([[       nan],
        [       nan],
        [       nan],
        ...,
        [0.52156863],
        [0.51764706],
        [0.51764706]]),
 'd_signal': None,
 'e_p_signal': None,
 'e_d_signal': None,
 'file_name': ['3269321_0001.dat'],
 'fmt': ['80'],
 'samps_per_frame': [1],
 'skew': [None],
 'byte_offset': [None],
 'adc_gain': [255.0],
 'baseline': [-128],
 'units': ['NU'],
 'adc_res': [8],
 'adc_zero': [0],
 'init_value': [-128],
 'checksum': [-25757],
 'block_size': [0]}
TypeError: 'AxesSubplot' object is not subscriptable
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-8c49de64b107> in <module>
      6 display(record.__dict__)
      7 
----> 8 wfdb.plot_wfdb(record=record, title='Record p000878/3269321_0001')

~\Anaconda3\lib\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),

~\Anaconda3\lib\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)
    117 
    118     if signal is not None:
--> 119         plot_signal(signal, sig_len, n_sig, fs, time_units, sig_style, axes)
    120 
    121     if ann_samp is not None:

~\Anaconda3\lib\site-packages\wfdb\plot\plot.py in plot_signal(signal, sig_len, n_sig, fs, time_units, sig_style, axes)
    281     else:
    282         for ch in range(n_sig):
--> 283             axes[ch].plot(t, signal[:,ch], sig_style[ch], zorder=3)
    284 
    285 

TypeError: 'AxesSubplot' object is not subscriptable

Can you tell me what I am doing wrong?

(I'm using Python 3.8.8.)

@jensmetzner
Copy link
Author

jensmetzner commented Aug 3, 2021

When I remove the indexing in line plot.py:283 to axes.plot(t, signal[:,ch], sig_style[ch], zorder=3) and comment out label_figure call, the plot is displayed correctly. I think it is related to this case.

Same error with label_figure.

@bemoody
Copy link
Collaborator

bemoody commented Oct 1, 2021

This was fixed in version 3.4.1 (see pull #308).

@bemoody bemoody closed this as completed Oct 1, 2021
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