2

2D NumPy 配列から複数の時系列データ (電圧) を表示する複数行プロットを作成しようとしています。2x10 配列から 10 個のデータ ポイントを含む 2 つの線を単純にプロットしようと始めましたが、デバッグできない大量のエラー出力を取得せずにこれを機能させることさえできません。

輸入品:

import numpy
from traits.api import HasTraits, Instance
from traitsui.api import View, Item
from chaco.api import MultiLinePlot, ArrayDataSource, MultiArrayDataSource
from enable.component_editor import ComponentEditor

テスト配列:

test_array = numpy.random.rand(10,2)

表示クラス:

class Multi_line_graph(HasTraits):

    plot = Instance(MultiLinePlot)

    traits_view = View(
    Item('plot',editor=ComponentEditor(), show_label=False),
    width=1024, height=768, resizable=True, title="EEG Preview")

    def __init__(self, my_data):
        super(Multi_line_graph, self).__init__()

        x = ArrayDataSource(numpy.arange(1, my_data.shape[0]))

        y = my_data.transpose()   #since my data columnwise
        y = MultiArrayDataSource(y)

        yidx = ArrayDataSource(numpy.arange(y.get_shape()[0]))

        plot = MultiLinePlot(index=x, yindex=yidx, value=y)

        self.plot = plot

クラスのインスタンスを作成:

my_graph = Multi_line_graph(test_array)

表示 (特性の構成):

my_graph.configure_traits()

次に、ウィンドウが表示されますが、Python カーネルがハングしてクラッシュし、シェルに次のエラーが表示されます。

Exception occurred in traits notification handler for object: <chaco.multi_line_plot.MultiLinePlot object at 0x000000000D0CFD58>, trait: bounds_items, old value: <undefined>, new value: <traits.trait_handlers.TraitListEvent object at 0x000000000D18C908>
Traceback (most recent call last):
File "C:\Users\pzl46097\AppData\Local\Enthought\Canopy\User\lib\site-packages\traits\trait_notifiers.py", line 340, in __call__
self.handler( *args )
File "C:\Users\pzl46097\AppData\Local\Enthought\Canopy\User\lib\site-packages\chaco\base_xy_plot.py", line 613, in _bounds_items_changed
self._update_mappers()
File "C:\Users\pzl46097\AppData\Local\Enthought\Canopy\User\lib\site-packages\chaco\base_xy_plot.py", line 594, in _update_mappers
x_mapper.screen_bounds = (x, x2)
AttributeError: 'NoneType' object has no attribute 'screen_bounds'
Exception occurred in traits notification handler for object: <chaco.multi_line_plot.MultiLinePlot object at 0x000000000D0CFD58>, trait: bounds_items, old value: <undefined>, new value: <traits.trait_handlers.TraitListEvent object at 0x000000000D0C4C88>
Traceback (most recent call last):
File "C:\Users\pzl46097\AppData\Local\Enthought\Canopy\User\lib\site-packages\traits\trait_notifiers.py", line 340, in __call__
self.handler( *args )
File "C:\Users\pzl46097\AppData\Local\Enthought\Canopy\User\lib\site-packages\chaco\base_xy_plot.py", line 613, in _bounds_items_changed
self._update_mappers()
File "C:\Users\pzl46097\AppData\Local\Enthought\Canopy\User\lib\site-packages\chaco\base_xy_plot.py", line 594, in _update_mappers
x_mapper.screen_bounds = (x, x2)
AttributeError: 'NoneType' object has no attribute 'screen_bounds'
Exception occurred in traits notification handler.
Please check the log file for details.

これが何を意味するのかよくわかりません。次の API ドキュメントを読み、再読しました。

http://docs.enthought.com/chaco/api/renderers.html#multilineplot

また、次のユーザー ガイド ドキュメントも参照してください。

http://docs.enthought.com/chaco/user_manual/plot_types.html#multi-line-plot

しかし、このクラスに関する他のドキュメントはないようです。それが維持されておらず、壊れている可能性があるのか​​ 、それとも何か間違っているのか疑問に思っています(私はChacoを約1週間しか使用しておらず、ライブラリは私にとって新しいものであり、Pythonの一般的なOOPと同様です) )。

助けてくれてありがとう..

4

1 に答える 1