dear list,

can someone tell me why I don't see anything when I run this script?
it is a modified version of the traits example...
I expected to see three plots with one line each...

from enthought.traits.api import HasTraits, Instance, Range, Array,
on_trait_change, Property,cached_property, Bool
from enthought.traits.ui.api import View, Item
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from matplotlib.figure import Figure
from matplotlib.axes import Axes
from matplotlib.lines import Line2D
from enthought.traits.ui.api import CustomEditor
import wx
import numpy

def MakePlot(parent, editor):
        fig = editor.object.figure
        panel = wx.Panel(parent, -1)
        canvas = FigureCanvasWxAgg(panel, -1, fig)
        toolbar = NavigationToolbar2Wx(canvas)
        toolbar.Realize()
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(canvas,1,wx.EXPAND|wx.ALL,1)
        sizer.Add(toolbar,0,wx.EXPAND|wx.ALL,1)
        panel.SetSizer(sizer)
        canvas.SetMinSize((300,600))
        return panel

class PlotModel(HasTraits):

        figure = Instance(Figure, ())
        axes1 = Instance(Axes)
        axes2 = Instance(Axes)
        axes3 = Instance(Axes)
        line1 = Instance(Line2D)
        line2 = Instance(Line2D)
        line3 = Instance(Line2D)
        _draw_pending = Bool(False) #a flag to throttle the redraw rate
        # a variable parameter
        x = Array(value=numpy.arange(1, 31))
        x2 = Array(value=numpy.arange(1, 31))
        x3 = Array(value=numpy.arange(1, 31))
        # a dependent variable
        y = Array(value=numpy.arange(1, 31))
        y2 = Array(value=numpy.arange(1, 31))
        y3 = Array(value=numpy.arange(1, 31))
        
        traits_view = View(
                                        Item('figure',
                                                 editor=CustomEditor(MakePlot),
                                                 resizable=True,
                                                 show_label=False),
                                        resizable=False,
                                        width=400,
                                        height=750
                                        )

        def _axes1_default(self):
                return self.figure.add_subplot(311)

        def _axes2_default(self):
                return self.figure.add_subplot(312)

        def _axes3_default(self):
                return self.figure.add_subplot(313)

        def _line1_default(self):
                return self.axes1.plot(self.x, self.y)[0]

        def _line2_default(self):
                return self.axes2.plot(self.x2, self.y2)[0]

        def _line3_default(self):
                return self.axes3.plot(self.x3, self.y3)[0]

        def redraw(self):
                if self._draw_pending:
                        return
                canvas = self.figure.canvas
                if canvas is None:
                        return
                def _draw():
                        canvas.draw()
                        self._draw_pending = False
                wx.CallLater(50, _draw).Start()
                self._draw_pending = True

if __name__=="__main__":
        model = PlotModel()
        model.configure_traits(model.redraw())


thank you,
simone

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to