Skip to content

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

Closed

Description

@jensmetzner

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.)

Activity

  1. jensmetzner commented on Aug 3, 2021

    @jensmetzner
    Author

    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.

  2. bemoody commented on Oct 1, 2021

    @bemoody
    Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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