ScatterInspector
chaco ツールやScatterInspectorOverlay
enamlを使用したいと考えています。非常に単純なコントローラーとビュー (以下のソース) をセットアップしましたが、続行する方法を決定できません。私が見つけた最小限の古い例に従おうとしましたが、うまくいきませんでした。
のオーバーレイ部分のコメントを外すとScatterInspectorOverlay
、コードの実行に失敗します
ファイル ".../chaco/scatter_inspector_overlay.py"、51 行目、オーバーレイの場合、plot または not plot.index または not getattr(plot, "value", True):
オーバーレイ部分をコメントアウトすると、もちろん、必要なオーバーレイの動作が得られず、マウスを動かすと、
ファイル「.../chaco/tools/scatter_inspector.py」、48 行目、normal_mouse_move 内 index = plot.map_index((event.x, event.y), threshold=self.threshold)
view.enaml ソース:
from enaml.widgets.api import (
Window, Container, EnableCanvas,
)
enamldef ScatterView(Window):
attr controller
title = "Scatter Inspector Test"
initial_size = (640,480)
Container:
EnableCanvas:
component = controller.scatter_plot
controller.py ソース:
import enaml
from enaml.stdlib.sessions import show_simple_view
from traits.api import HasTraits, Instance
from chaco.api import Plot, ArrayPlotData, ScatterInspectorOverlay
from chaco.tools.api import ScatterInspector
from numpy import linspace, sin
class ScatterController(HasTraits):
scatter_plot = Instance(Plot)
def _scatter_plot_default(self):
# data
x = linspace(-14, 14, 100)
y = sin(x) * x**3
plotdata = ArrayPlotData(x = x, y = y)
# plot
scatter_plot = Plot(plotdata)
renderer = scatter_plot.plot(("x", "y"), type="scatter", color="red")
# inspector
scatter_plot.tools.append(ScatterInspector(scatter_plot))
# overlay
# scatter_plot.overlays.append( ScatterInspectorOverlay(
# scatter_plot,
# hover_color = 'red',
# hover_marker_size = 6,
# selection_marker_size = 6,
# selection_color = 'yellow',
# selection_outline_color='purple',
# selection_line_width = 3
# ))
#return
return scatter_plot
if __name__ == "__main__":
with enaml.imports():
from view import ScatterView
main_controller = ScatterController()
window = ScatterView(controller=ScatterController())
show_simple_view(window)