0
このプログラムはchaco 3.2ではうまく動作していましたが、chaco 4ではスクロールバーがまったく表示されませんでした。最新のchacoリリースではスクロールバーが機能しません
私は問題を見つけるか、回避策を見つけることをお勧めします。
PanToolが回避策になる可能性がありますが、これはマウスで使用される一部の担当者と競合します。
#!/usr/bin/env python
# Major library imports
from numpy import linspace
from scipy.special import jn
# Enthought library imports
from enthought.enable.api import Component, ComponentEditor
from enthought.traits.api import HasTraits, Instance
from enthought.traits.ui.api import Item, Group, View
# Chaco imports
from enthought.chaco.api import ArrayPlotData, VPlotContainer, \
Plot, OverlayPlotContainer, add_default_axes, add_default_grids
from enthought.chaco.plotscrollbar import PlotScrollBar
from enthought.chaco.tools.api import PanTool, ZoomTool
#===============================================================================
# # Create the Chaco plot.
#===============================================================================
def _create_plot_component():
# Create some x-y data series to plot
x = linspace(-2.0, 10.0, 100)
pd = ArrayPlotData(index = x)
for i in range(5):
pd.set_data("y" + str(i), jn(i,x))
# Create some line plots of some of the data
plot1 = Plot(pd)
plot1.plot(("index", "y0", "y1", "y2"), name="j_n, n<3", color="red")[0]
p = plot1.plot(("index", "y3"), name="j_3", color="blue")[0]
# Add the scrollbar
plot1.padding_top = 0
p.index_range.high_setting = 1
# Create a container and add our plots
container = OverlayPlotContainer(padding = 5,fill_padding = True,
bgcolor = "lightgray", use_backbuffer=True)
hscrollbar = PlotScrollBar(component=p, mapper=p.index_mapper,axis="index", resizable="",use_backbuffer = False,
height=15,position=(0,0))
hscrollbar.force_data_update()
plot1.overlays.append(hscrollbar)
hgrid,vgrid = add_default_grids(plot1)
add_default_axes(plot1)
container.add(plot1)
container.invalidate_and_redraw()
return container
#===============================================================================
# Attributes to use for the plot view.
size=(900,500)
title="Scrollbar example"
#===============================================================================
# # Demo class that is used by the demo.py application.
#===============================================================================
class Demo(HasTraits):
plot = Instance(Component)
traits_view = View(
Group(
Item('plot', editor=ComponentEditor(size=size),
show_label=False),
orientation = "vertical"),
resizable=True, title=title
)
def _plot_default(self):
return _create_plot_component()
demo = Demo()
if __name__ == "__main__":
demo.configure_traits()
#--EOF---
これはhttps://github.com/enthought/chaco/issuesに登録してください。 –