SlideShare a Scribd company logo
1 of 53
Download to read offline
Chaco step-by-step


                                 July 17, 2009



Monday, February 22, 2010
http://www.enthought.com/




Monday, February 22, 2010
Enthought Python Distribution (EPD)

    MORE THAN FIFTY INTEGRATED PACKAGES

      • Python 2.5.2                   • Database (MySQL, SQLLite, etc.)
      • Science (NumPy, SciPy, etc.)   • Data Storage (HDF, NetCDF, etc.)
      • Plotting (Chaco, Matplotlib)   • Networking (twisted)
      • Visualization (VTK, Mayavi)    • User Interface (wxPython, Traits UI)
      • Multi-language Integration     • Enthought Tool Suite
        (SWIG,Pyrex, f2py, weave)        (Application Development Tools)




Monday, February 22, 2010
Enthought Python Distribution (EPD)




Monday, February 22, 2010
Enthought Python Distribution (EPD)



              Selections from our training courses including:
              explanations, demonstrations, and tips

              For subscribers to Enthought Python Distribution
              (EPD)

              Offered once a month for 60-90 minutes
              depending on questions



Monday, February 22, 2010
Enthought Training Courses




                            Python Basics, NumPy,
                            SciPy, Matplotlib, Traits,
                            TraitsUI, Chaco…



Monday, February 22, 2010
Upcoming Training Classes
      September 21 – 25, 2009
           Introduction to Scientific Computing with Python
           Austin, Texas
      October 19 – 22, 2009
           Python for Science, Eng., and Financial Analysis
           Silicon Valley, California
      November 9 – 12, 2009
           Python for Science, Eng., and Financial Analysis
           Chicago, Illinois
      December 7 – 11, 2009
           Introduction to Scientific Computing with Python
           Austin, Texas
                             http://www.enthought.com/training/



Monday, February 22, 2010
Enthought Tool Suite        http://code.enthought.com/




Monday, February 22, 2010
Rich Client App (Geophysics, Finance, Etc)
               Testing Framework Scripting Interface                   Data Display
         Equipment              Compliance     Scientific   Database   Chaco         UI
          Interface               Tools       Algorithms     Access    Plotting   Elements




Monday, February 22, 2010
Monday, February 22, 2010
Chaco: Interactive Graphics




Monday, February 22, 2010
Introduction


         • Chaco is a plotting application toolkit
         • You can build simple, static plots




Monday, February 22, 2010
Introduction

       • Chaco is a plotting application toolkit
       • You can build simple, static plots
       • You can also build rich, interactive
         visualizations:




Monday, February 22, 2010
“Script-oriented” Plotting

 •   from numpy import *
 •   from enthought.chaco.shell import *
 •   x = linspace(-2*pi, 2*pi, 100)
 •   y = sin(x)
 •   plot(x, y, 'r-')
 •   title('First plot')
 •   ytitle('sin(x)')
 •   show()




Monday, February 22, 2010
“Application-oriented” Plotting

 •    class LinePlot(HasTraits):
 •        plot = Instance(Plot)
 •        traits_view = View(
 •            Item('plot',editor=ComponentEditor(),
 •                 show_label=False),
 •            width=500, height=500,
 •            resizable=True,
 •            title="Chaco Plot")

 •        def __init__(self):
 •            x = linspace(-14, 14, 100)
 •            y = sin(x) * x**3
 •            plotdata = ArrayPlotData(x = x, y = y)
 •            plot = Plot(plotdata)
 •            plot.plot(("x", "y"), type="line",
 •                      color="blue")
 •            plot.title = "sin(x) * x^3"
 •            self.plot = plot

 •    if __name__ == "__main__":
 •        LinePlot().configure_traits()




Monday, February 22, 2010
First Plot

  class LinePlot(HasTraits):
      plot = Instance(Plot)
      traits_view = View(
          Item('plot', editor=ComponentEditor(), show_label=False),
          width=500, height=500,
          resizable=True,
          title="Chaco Plot")

         def __init__(self):
             x = linspace(-14, 14, 100)
             y = sin(x) * x**3
             plotdata = ArrayPlotData(x = x, y = y)

               plot = Plot(plotdata)
               plot.plot(("x", "y"), type="line", color="blue")
               plot.title = "sin(x) * x^3"
               self.plot = plot




Monday, February 22, 2010
First Plot

  class LinePlot(HasTraits):
      plot = Instance(Plot)
      traits_view = View(
          Item('plot',editor=ComponentEditor(), show_label=False),
          width=500, height=500,
          resizable=True,
          title="Chaco Plot")

         def __init__(self):
             x = linspace(-14, 14, 100)
             y = sin(x) * x**3
             plotdata = ArrayPlotData(x = x, y = y)

               plot = Plot(plotdata)
               plot.plot(("x", "y"), type="line", color="blue")
               plot.title = "sin(x) * x^3"
               self.plot = plot




Monday, February 22, 2010
First Plot

  class LinePlot(HasTraits):
      plot = Instance(Plot)
      traits_view = View(
          Item('plot',editor=ComponentEditor(), show_label=False),
          width=500, height=500,
          resizable=True,
          title="Chaco Plot")

         def __init__(self):
             x = linspace(-14, 14, 100)
             y = sin(x) * x**3
             plotdata = ArrayPlotData(x = x, y = y)

               plot = Plot(plotdata)
               plot.plot(("x", "y"), type="line", color="blue")
               plot.title = "sin(x) * x^3"
               self.plot = plot




Monday, February 22, 2010
First Plot

  class LinePlot(HasTraits):
      plot = Instance(Plot)
      traits_view = View(
          Item('plot',editor=ComponentEditor(), show_label=False),
          width=500, height=500,
          resizable=True,
          title="Chaco Plot")

         def __init__(self):
             x = linspace(-14, 14, 100)
             y = sin(x) * x**3
             plotdata = ArrayPlotData(x = x, y = y)

               plot = Plot(plotdata)
               plot.plot(("x", "y"), type="line", color="blue")
               plot.title = "sin(x) * x^3"
               self.plot = plot




Monday, February 22, 2010
First Plot

  class LinePlot(HasTraits):
      plot = Instance(Plot)
      traits_view = View(
          Item('plot',editor=ComponentEditor(), show_label=False),
          width=500, height=500,
          resizable=True,
          title="Chaco Plot")

         def __init__(self):
             x = linspace(-14, 14, 100)
             y = sin(x) * x**3
             plotdata = ArrayPlotData(x = x, y = y)

               plot = Plot(plotdata)
               plot.plot(("x", "y"), type="line", color="blue")
               plot.title = "sin(x) * x^3"
               self.plot = plot




Monday, February 22, 2010
First Plot

  class LinePlot(HasTraits):
      plot = Instance(Plot)
      traits_view = View(
          Item('plot',editor=ComponentEditor(), show_label=False),
          width=500, height=500,
          resizable=True,
          title="Chaco Plot")

         def __init__(self):
             x = linspace(-14, 14, 100)
             y = sin(x) * x**3
             plotdata = ArrayPlotData(x = x, y = y)

               plot = Plot(plotdata)
               plot.plot(("x", "y"), type="line", color="blue")
               plot.title = "sin(x) * x^3"
               self.plot = plot




Monday, February 22, 2010
First Plot

  class LinePlot(HasTraits):
      plot = Instance(Plot)
      traits_view = View(
          Item('plot',editor=ComponentEditor(), show_label=False),
          width=500, height=500,
          resizable=True,
          title="Chaco Plot")

         def __init__(self):
             x = linspace(-14, 14, 100)
             y = sin(x) * x**3
             plotdata = ArrayPlotData(x = x, y = y)

               plot = Plot(plotdata)
               plot.plot(("x", "y"), type="line", color="blue")
               plot.title = "sin(x) * x^3"
               self.plot = plot




Monday, February 22, 2010
First Plot


   Finally, do something when this script
   is executed:

  if __name__ == "__main__":
         LinePlot().configure_traits()




Monday, February 22, 2010
Scatter Plot

 •    class ScatterPlot(HasTraits):
 •        plot = Instance(Plot)
 •        traits_view = View(
 •            Item('plot', editor=ComponentEditor(),
 •                 show_label=False),
 •            width=500, height=500,
 •            resizable=True,
 •            title="Chaco Plot")


 •         def __init__(self):
 •             x = linspace(-14, 14, 100)
 •             y = sin(x) * x**3
 •             plotdata = ArrayPlotData(x = x, y = y)
 •             plot = Plot(plotdata)
 •             plot.plot(("x", "y"), type="scatter",
 •                       color="blue")
 •             self.plot = plot


 •    if __name__ == "__main__":




Monday, February 22, 2010
Image Plot

 •    class ImagePlot(HasTraits):
 •        plot = Instance(Plot)
 •        traits_view = View(
 •            Item('plot', editor=ComponentEditor(),
 •                 show_label=False),
 •            width=500, height=500,
 •            resizable=True,
 •            title=”Chaco Plot”)


 •         def __init__(self):
 •             x = linspace(0, 10, 50)
 •             y = linspace(0, 5, 50)
 •             xgrid, ygrid = meshgrid(x, y)
 •             z = exp(-(xgrid*xgrid+ygrid*ygrid)/100)
 •             plotdata = ArrayPlotData(imagedata = z)
 •             plot = Plot(plotdata)
 •             plot.img_plot("imagedata", xbounds=x,
 •                           ybounds=y, colormap=jet)
 •             self.plot = plot


 •    if __name__ == "__main__":
 •        ImagePlot().configure_traits()




Monday, February 22, 2010
A Slight Modification
 •    class OverlappingPlot(HasTraits):
 •        plot = Instance(Plot)
 •        traits_view = View(
 •            Item('plot',editor=ComponentEditor(),
 •                 show_label=False),
 •            width=500, height=500,
 •            resizable=True,
 •            title=”Chaco Plot”)

 •        def __init__(self):
 •            x = linspace(-14, 14, 100)
 •            y = x/2 * sin(x)
 •            y2 = cos(x)
 •            plotdata = ArrayPlotData(x=x,y=y,y2=y2)
 •            plot = Plot(plotdata)
 •            plot.plot(("x", "y"), type="scatter",
 •                color="blue")
 •            plot.plot(("x", "y2"), type="line",
 •                      color="red")
 •            self.plot = plot


 •    if __name__ == "__main__":
 •        OverlappingPlot().configure_traits()




Monday, February 22, 2010
Editing Plot Traits
•    from enthought.traits.api import Int
•    from enthought.enable.api import ColorTrait
•    from enthought.chaco.api import marker_trait

•    class ScatterPlotTraits(HasTraits):
•        plot = Instance(Plot)
•        color = ColorTrait("blue")
•        marker = marker_trait
•        marker_size = Int(4)




Monday, February 22, 2010
Editing Plot Traits
•    from enthought.traits.api import Int
•    from enthought.enable.api import ColorTrait
•    from enthought.chaco.api import marker_trait

•    class ScatterPlotTraits(HasTraits):
•        plot = Instance(Plot)
•        color = ColorTrait("blue")
•        marker = marker_trait
•        marker_size = Int(4)
•        traits_view = View(
•            Group(
•                Item('color', label="Color", style="custom"),
•                Item('marker', label="Marker"),
•                Item('marker_size', label="Size"),
•                Item('plot', editor=ComponentEditor(),
•                     show_label=False),
•                orientation = "vertical"
•                ),
•            width=500, height=500,
•            resizable=True,
•            title="Chaco Plot")




Monday, February 22, 2010
Editing Plot Traits
•       def __init__(self):
•
•             x = linspace(-14, 14, 100)
•             y = sin(x) * x**3
•             plotdata = ArrayPlotData(x = x, y = y)
•
•             plot = Plot(plotdata)
•
•             self.renderer = plot.plot(("x", "y"), type="scatter",
•                                       color="blue")[0]
•             self.plot = plot




Monday, February 22, 2010
Editing Plot Traits
•       def __init__(self):
•
•             x = linspace(-14, 14, 100)
•             y = sin(x) * x**3
•             plotdata = ArrayPlotData(x = x, y = y)
•
•             plot = Plot(plotdata)
•
•             self.renderer = plot.plot(("x", "y"), type="scatter",
•                                       color="blue")[0]
•             self.plot = plot

•       def _color_changed(self):
•           self.renderer.color = self.color




Monday, February 22, 2010
Editing Plot Traits
•       def __init__(self):
•
•             x = linspace(-14, 14, 100)
•             y = sin(x) * x**3
•             plotdata = ArrayPlotData(x = x, y = y)
•
•             plot = Plot(plotdata)
•
•             self.renderer = plot.plot(("x", "y"), type="scatter",
•                                       color="blue")[0]
•             self.plot = plot

•       def _color_changed(self):
•           self.renderer.color = self.color

•       def _marker_changed(self):
•           self.renderer.marker = self.marker

•       def _marker_size_changed(self):
•           self.renderer.marker_size = self.marker_size




Monday, February 22, 2010
Editing Plot Traits




Monday, February 22, 2010
Tools
    from enthought.chaco.tools.api import PanTool, ZoomTool, DragZoom

    class ToolsExample(HasTraits):
        plot = Instance(Plot)
        traits_view = View(
            Item('plot',editor=ComponentEditor(), show_label=False),
            width=500, height=500,
            resizable=True,
            title="Chaco Plot")

         def __init__(self):
             x = linspace(-14, 14, 100)
             y = sin(x) * x**3
             plotdata = ArrayPlotData(x = x, y = y)
             plot = Plot(plotdata)
             plot.plot(("x", "y"), type="line", color="blue")

               plot.tools.append(PanTool(plot))
               plot.tools.append(ZoomTool(plot))
               plot.tools.append(DragZoom(plot, drag_button="right"))

               self.plot = plot




Monday, February 22, 2010
Tool Chooser
    from enthought.traits.ui.api import CheckListEditor

    class ToolsExample(HasTraits):
        plot = Instance(Plot)
        tools = List(editor=CheckListEditor(values = ["PanTool",
                                     "SimpleZoom", "DragZoom"]))




Monday, February 22, 2010
Tool Chooser
    from enthought.traits.ui.api import CheckListEditor

    class ToolsExample(HasTraits):
        plot = Instance(Plot)
        tools = List(editor=CheckListEditor(values = ["PanTool",
                                     "SimpleZoom", "DragZoom"]))

         def __init__(self):
             x = linspace(-14, 14, 500)
             y = sin(x) * x**3
             plotdata = ArrayPlotData(x = x, y = y)
             plot = Plot(plotdata)
             plot.plot(("x", "y"), type="line", color="blue")

               plot.tools.append(PanTool(plot))
               plot.tools.append(ZoomTool(plot))
               plot.tools.append(DragZoom(plot, drag_button="right"))

               self.plot = plot




Monday, February 22, 2010
Tool Chooser

  def _tools_changed(self):
      classes = [eval(class_name) for class_name in self.tools]

        for tool in self.plot.tools:
            if tool.__class__ not in classes:
                self.plot.tools.remove(tool)
            else:
                classes.remove(tool.__class__)

        for cls in classes:
            self.plot.tools.append(cls(self.plot))
        return




Monday, February 22, 2010
Tool Chooser

  def _tools_changed(self):
      classes = [eval(class_name) for class_name in self.tools]

        for tool in self.plot.tools:
            if tool.__class__ not in classes:
                self.plot.tools.remove(tool)
            else:
                classes.remove(tool.__class__)

        for cls in classes:
            self.plot.tools.append(cls(self.plot))
        return




Monday, February 22, 2010
Tool Chooser

  def _tools_changed(self):
      classes = [eval(class_name) for class_name in self.tools]

        for tool in self.plot.tools:
            if tool.__class__ not in classes:
                self.plot.tools.remove(tool)
            else:
                classes.remove(tool.__class__)

        for cls in classes:
            self.plot.tools.append(cls(self.plot))
        return




Monday, February 22, 2010
Tool Chooser

  def _tools_changed(self):
      classes = [eval(class_name) for class_name in self.tools]

        for tool in self.plot.tools:
            if tool.__class__ not in classes:
                self.plot.tools.remove(tool)
            else:
                classes.remove(tool.__class__)

        for cls in classes:
            self.plot.tools.append(cls(self.plot))
        return




Monday, February 22, 2010
Tool Chooser

  def _tools_changed(self):
      classes = [eval(class_name) for class_name in self.tools]

        for tool in self.plot.tools:
            if tool.__class__ not in classes:
                self.plot.tools.remove(tool)
            else:
                classes.remove(tool.__class__)

        for cls in classes:
            self.plot.tools.append(cls(self.plot))
        return




Monday, February 22, 2010
Tool Chooser

  def _tools_changed(self):
      classes = [eval(class_name) for class_name in self.tools]

        for tool in self.plot.tools:
            if tool.__class__ not in classes:
                self.plot.tools.remove(tool)
            else:
                classes.remove(tool.__class__)

        for cls in classes:
            self.plot.tools.append(cls(self.plot))
        return




Monday, February 22, 2010
Tool Chooser

  def _tools_changed(self):
      classes = [eval(class_name) for class_name in self.tools]

        for tool in self.plot.tools:
            if tool.__class__ not in classes:
                self.plot.tools.remove(tool)
            else:
                classes.remove(tool.__class__)

        for cls in classes:
            self.plot.tools.append(cls(self.plot))
        return




Monday, February 22, 2010
Tool Chooser
  class ToolChooserExample(HasTraits):

      plot = Instance(Plot)
      tools = List(editor=CheckListEditor(values = ["PanTool", "ZoomTool",
  "DragZoom"]))
      traits_view = View(Item("tools", label="Tools", style="custom"),
                         Item('plot', editor=ComponentEditor(), show_label=False),
                          width=800, height=600, resizable=True,
                         title="Tool Chooser")

        def __init__(self):
            ...

        def _tools_changed(self):
            classes = [eval(class_name) for class_name in self.tools]
            # Remove all tools that are not in the enabled list in self.tools
            for tool in self.plot.tools:
                if tool.__class__ not in classes:
                    self.plot.tools.remove(tool)
                else:
                    classes.remove(tool.__class__)
            # Create new instances of tools for the remaining tool classes
            for cls in classes:
                self.plot.tools.append(cls(self.plot))
            return




Monday, February 22, 2010
Tool Chooser




Monday, February 22, 2010
Writing a Custom Tool
    from enthought.enable.api import BaseTool

    class CustomTool(BaseTool):
        def normal_mouse_move(self, event):
            print "Screen point:", event.x, event.y

    class ScatterPlot(HasTraits):
        plot = Instance(Plot)
        traits_view = View(Item('plot', editor=ComponentEditor(),
                                show_label=False),
                           width=800, height=600, resizable=True,
                           title="Custom Tool")

          def _plot_default(self):
              x = linspace(-14, 14, 100)
              y = sin(x) * x**3
              plotdata = ArrayPlotData(x = x, y = y)
              plot = Plot(plotdata)
              plot.plot(("x", "y"), type="scatter", color="blue")
              plot.tools.append(CustomTool(plot))
              return plot




Monday, February 22, 2010
Writing a Custom Tool
    from enthought.enable.api import BaseTool

    class CustomTool(BaseTool):
        def normal_mouse_move(self, event):
            print "Screen point:", event.x, event.y

    class ScatterPlot(HasTraits):
        plot = Instance(Plot)
        traits_view = View(Item('plot', editor=ComponentEditor(),
                                show_label=False),
                           width=800, height=600, resizable=True,
                           title="Custom Tool")

          def _plot_default(self):
              x = linspace(-14, 14, 100)
              y = sin(x) * x**3
              plotdata = ArrayPlotData(x = x, y = y)
              plot = Plot(plotdata)
              plot.plot(("x", "y"), type="scatter", color="blue")
              plot.tools.append(CustomTool(plot))
              return plot




Monday, February 22, 2010
Writing a Custom Tool
    from enthought.enable.api import BaseTool

    class CustomTool(BaseTool):
        def normal_mouse_move(self, event):
            print "Screen point:", event.x, event.y

    class ScatterPlot(HasTraits):
        plot = Instance(Plot)
        traits_view = View(Item('plot', editor=ComponentEditor(),
                                show_label=False),
                           width=800, height=600, resizable=True,
                           title=”Custom Tool”)

          def _plot_default(self):
              x = linspace(-14, 14, 100)
              y = sin(x) * x**3
              plotdata = ArrayPlotData(x = x, y = y)
              plot = Plot(plotdata)
              plot.plot(("x", "y"), type="scatter", color="blue")
              plot.tools.append(CustomTool(plot))
              return plot




Monday, February 22, 2010
Writing a Custom Tool

    class CustomTool(BaseTool):
        def normal_mouse_move(self, event):
            print "Screen point:", event.x, event.y

          def normal_left_down(self, event):
              print "Mouse went down at", event.x, event.y

          def normal_left_up(self, event):
              print "Mouse went up at:", event.x, event.y




Monday, February 22, 2010
Writing a Custom Tool

    class CustomTool(BaseTool):
            event_state = Enum("normal", "mousedown")

                def normal_mouse_move(self, event):
                    print "Screen:", event.x, event.y

                def normal_left_down(self, event):
                    self.event_state = "mousedown"
                    event.handled = True

                def mousedown_left_up(self, event):
                    self.event_state = "normal"
                    event.handled = True




Monday, February 22, 2010
Writing a Custom Tool

    class CustomTool(BaseTool):

                event_state = Enum("normal", "mousedown")

                def normal_mouse_move(self, event):
                    print "Screen:", event.x, event.y

                def normal_left_down(self, event):
                    self.event_state = "mousedown"
                    event.handled = True

                def mousedown_mouse_move(self, event):
                    print "Data:", self.component.map_data((event.x, event.y))

                def mousedown_left_up(self, event):
                    self.event_state = "normal"
                    event.handled = True




Monday, February 22, 2010
Additional Tutorial Examples
                            Custom Overlay




Monday, February 22, 2010
Additional Tutorial Examples
               Custom Overlay with Dataspace Option




Monday, February 22, 2010
More information
      • Web page:
         http://code.enthought.com/projects/chaco

      • Wiki:
              https://svn.enthought.com/enthought/wiki/ChacoProject

      • Gallery:
              http://code.enthought.com/projects/chaco/gallery.php


      • Mailing lists:
          enthought-dev@enthought.com,
          chaco-users@enthought.com




Monday, February 22, 2010

More Related Content

What's hot

MDSD for iPhone and Android
MDSD for iPhone and AndroidMDSD for iPhone and Android
MDSD for iPhone and AndroidHeiko Behrens
 
Python data structures
Python data structuresPython data structures
Python data structureskalyanibedekar
 
Observational Science With Python and a Webcam
Observational Science With Python and a WebcamObservational Science With Python and a Webcam
Observational Science With Python and a WebcamIntellovations, LLC
 
TensorFlow Tutorial
TensorFlow TutorialTensorFlow Tutorial
TensorFlow TutorialNamHyuk Ahn
 
Gentlest Introduction to Tensorflow - Part 3
Gentlest Introduction to Tensorflow - Part 3Gentlest Introduction to Tensorflow - Part 3
Gentlest Introduction to Tensorflow - Part 3Khor SoonHin
 
Gentlest Introduction to Tensorflow
Gentlest Introduction to TensorflowGentlest Introduction to Tensorflow
Gentlest Introduction to TensorflowKhor SoonHin
 
Swift, via "swift-2048"
Swift, via "swift-2048"Swift, via "swift-2048"
Swift, via "swift-2048"Austin Zheng
 
かとうの Kotlin 講座 こってり版
かとうの Kotlin 講座 こってり版かとうの Kotlin 講座 こってり版
かとうの Kotlin 講座 こってり版Yutaka Kato
 
Airline reservation project using JAVA in NetBeans IDE
Airline reservation project using JAVA in NetBeans IDEAirline reservation project using JAVA in NetBeans IDE
Airline reservation project using JAVA in NetBeans IDEHimanshiSingh71
 
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 AutumnGoptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 AutumnMasashi Shibata
 
Артём Акуляков - F# for Data Analysis
Артём Акуляков - F# for Data AnalysisАртём Акуляков - F# for Data Analysis
Артём Акуляков - F# for Data AnalysisSpbDotNet Community
 
Object oriented programming in go
Object oriented programming in goObject oriented programming in go
Object oriented programming in goJaehue Jang
 

What's hot (20)

MDSD for iPhone and Android
MDSD for iPhone and AndroidMDSD for iPhone and Android
MDSD for iPhone and Android
 
Python bokeh cheat_sheet
Python bokeh cheat_sheet Python bokeh cheat_sheet
Python bokeh cheat_sheet
 
Python data structures
Python data structuresPython data structures
Python data structures
 
Python book
Python bookPython book
Python book
 
Cocos2dx 7.1-7.2
Cocos2dx 7.1-7.2Cocos2dx 7.1-7.2
Cocos2dx 7.1-7.2
 
Observational Science With Python and a Webcam
Observational Science With Python and a WebcamObservational Science With Python and a Webcam
Observational Science With Python and a Webcam
 
TensorFlow Tutorial
TensorFlow TutorialTensorFlow Tutorial
TensorFlow Tutorial
 
Gentlest Introduction to Tensorflow - Part 3
Gentlest Introduction to Tensorflow - Part 3Gentlest Introduction to Tensorflow - Part 3
Gentlest Introduction to Tensorflow - Part 3
 
TensorFlow
TensorFlowTensorFlow
TensorFlow
 
2011 11-mozcamp
2011 11-mozcamp2011 11-mozcamp
2011 11-mozcamp
 
Gentlest Introduction to Tensorflow
Gentlest Introduction to TensorflowGentlest Introduction to Tensorflow
Gentlest Introduction to Tensorflow
 
Lec2
Lec2Lec2
Lec2
 
Swift, via "swift-2048"
Swift, via "swift-2048"Swift, via "swift-2048"
Swift, via "swift-2048"
 
SVGo workshop
SVGo workshopSVGo workshop
SVGo workshop
 
かとうの Kotlin 講座 こってり版
かとうの Kotlin 講座 こってり版かとうの Kotlin 講座 こってり版
かとうの Kotlin 講座 こってり版
 
Airline reservation project using JAVA in NetBeans IDE
Airline reservation project using JAVA in NetBeans IDEAirline reservation project using JAVA in NetBeans IDE
Airline reservation project using JAVA in NetBeans IDE
 
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 AutumnGoptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
 
Mattbrenner
MattbrennerMattbrenner
Mattbrenner
 
Артём Акуляков - F# for Data Analysis
Артём Акуляков - F# for Data AnalysisАртём Акуляков - F# for Data Analysis
Артём Акуляков - F# for Data Analysis
 
Object oriented programming in go
Object oriented programming in goObject oriented programming in go
Object oriented programming in go
 

Similar to Chaco Step-by-Step

Writing a compiler in go
Writing a compiler in goWriting a compiler in go
Writing a compiler in goYusuke Kita
 
Python과 node.js기반 데이터 분석 및 가시화
Python과 node.js기반 데이터 분석 및 가시화Python과 node.js기반 데이터 분석 및 가시화
Python과 node.js기반 데이터 분석 및 가시화Tae wook kang
 
IAT334-Lab02-ArraysPImage.pptx
IAT334-Lab02-ArraysPImage.pptxIAT334-Lab02-ArraysPImage.pptx
IAT334-Lab02-ArraysPImage.pptxssuseraae9cd
 
Pointer Events in Canvas
Pointer Events in CanvasPointer Events in Canvas
Pointer Events in Canvasdeanhudson
 
Introduction to Go
Introduction to GoIntroduction to Go
Introduction to GoJaehue Jang
 
Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티
Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티
Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티JaeYeoul Ahn
 
Proxies are Awesome!
Proxies are Awesome!Proxies are Awesome!
Proxies are Awesome!Brendan Eich
 
Monads and Monoids by Oleksiy Dyagilev
Monads and Monoids by Oleksiy DyagilevMonads and Monoids by Oleksiy Dyagilev
Monads and Monoids by Oleksiy DyagilevJavaDayUA
 
Use the Matplotlib, Luke @ PyCon Taiwan 2012
Use the Matplotlib, Luke @ PyCon Taiwan 2012Use the Matplotlib, Luke @ PyCon Taiwan 2012
Use the Matplotlib, Luke @ PyCon Taiwan 2012Wen-Wei Liao
 
PLOTCON NYC: PlotlyJS.jl: Interactive plotting in Julia
PLOTCON NYC: PlotlyJS.jl: Interactive plotting in JuliaPLOTCON NYC: PlotlyJS.jl: Interactive plotting in Julia
PLOTCON NYC: PlotlyJS.jl: Interactive plotting in JuliaPlotly
 
Python basic
Python basic Python basic
Python basic sewoo lee
 
Presentation: Plotting Systems in R
Presentation: Plotting Systems in RPresentation: Plotting Systems in R
Presentation: Plotting Systems in RIlya Zhbannikov
 
Not Really Engineering, Barely a Science
Not Really Engineering, Barely a ScienceNot Really Engineering, Barely a Science
Not Really Engineering, Barely a ScienceRod Begbie
 
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」Ken'ichi Matsui
 
Python matplotlib cheat_sheet
Python matplotlib cheat_sheetPython matplotlib cheat_sheet
Python matplotlib cheat_sheetNishant Upadhyay
 

Similar to Chaco Step-by-Step (20)

Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
Writing a compiler in go
Writing a compiler in goWriting a compiler in go
Writing a compiler in go
 
Python과 node.js기반 데이터 분석 및 가시화
Python과 node.js기반 데이터 분석 및 가시화Python과 node.js기반 데이터 분석 및 가시화
Python과 node.js기반 데이터 분석 및 가시화
 
Py lecture5 python plots
Py lecture5 python plotsPy lecture5 python plots
Py lecture5 python plots
 
IAT334-Lab02-ArraysPImage.pptx
IAT334-Lab02-ArraysPImage.pptxIAT334-Lab02-ArraysPImage.pptx
IAT334-Lab02-ArraysPImage.pptx
 
Pointer Events in Canvas
Pointer Events in CanvasPointer Events in Canvas
Pointer Events in Canvas
 
Introduction to Go
Introduction to GoIntroduction to Go
Introduction to Go
 
Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티
Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티
Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티
 
Proxies are Awesome!
Proxies are Awesome!Proxies are Awesome!
Proxies are Awesome!
 
Monads and Monoids by Oleksiy Dyagilev
Monads and Monoids by Oleksiy DyagilevMonads and Monoids by Oleksiy Dyagilev
Monads and Monoids by Oleksiy Dyagilev
 
Use the Matplotlib, Luke @ PyCon Taiwan 2012
Use the Matplotlib, Luke @ PyCon Taiwan 2012Use the Matplotlib, Luke @ PyCon Taiwan 2012
Use the Matplotlib, Luke @ PyCon Taiwan 2012
 
PLOTCON NYC: PlotlyJS.jl: Interactive plotting in Julia
PLOTCON NYC: PlotlyJS.jl: Interactive plotting in JuliaPLOTCON NYC: PlotlyJS.jl: Interactive plotting in Julia
PLOTCON NYC: PlotlyJS.jl: Interactive plotting in Julia
 
Object-oriented Basics
Object-oriented BasicsObject-oriented Basics
Object-oriented Basics
 
Python basic
Python basic Python basic
Python basic
 
Ocr code
Ocr codeOcr code
Ocr code
 
Presentation: Plotting Systems in R
Presentation: Plotting Systems in RPresentation: Plotting Systems in R
Presentation: Plotting Systems in R
 
Not Really Engineering, Barely a Science
Not Really Engineering, Barely a ScienceNot Really Engineering, Barely a Science
Not Really Engineering, Barely a Science
 
ATS Programming
ATS ProgrammingATS Programming
ATS Programming
 
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
 
Python matplotlib cheat_sheet
Python matplotlib cheat_sheetPython matplotlib cheat_sheet
Python matplotlib cheat_sheet
 

More from Enthought, Inc.

Talk at NYC Python Meetup Group
Talk at NYC Python Meetup GroupTalk at NYC Python Meetup Group
Talk at NYC Python Meetup GroupEnthought, Inc.
 
Scientific Applications with Python
Scientific Applications with PythonScientific Applications with Python
Scientific Applications with PythonEnthought, Inc.
 
Scientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
Scientific Computing with Python Webinar March 19: 3D Visualization with MayaviScientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
Scientific Computing with Python Webinar March 19: 3D Visualization with MayaviEnthought, Inc.
 
February EPD Webinar: How do I...use PiCloud for cloud computing?
February EPD Webinar: How do I...use PiCloud for cloud computing?February EPD Webinar: How do I...use PiCloud for cloud computing?
February EPD Webinar: How do I...use PiCloud for cloud computing?Enthought, Inc.
 
Parallel Processing with IPython
Parallel Processing with IPythonParallel Processing with IPython
Parallel Processing with IPythonEnthought, Inc.
 
Scientific Computing with Python Webinar: Traits
Scientific Computing with Python Webinar: TraitsScientific Computing with Python Webinar: Traits
Scientific Computing with Python Webinar: TraitsEnthought, Inc.
 
Scientific Computing with Python Webinar 9/18/2009:Curve Fitting
Scientific Computing with Python Webinar 9/18/2009:Curve FittingScientific Computing with Python Webinar 9/18/2009:Curve Fitting
Scientific Computing with Python Webinar 9/18/2009:Curve FittingEnthought, Inc.
 
Scientific Computing with Python Webinar --- August 28, 2009
Scientific Computing with Python Webinar --- August 28, 2009Scientific Computing with Python Webinar --- August 28, 2009
Scientific Computing with Python Webinar --- August 28, 2009Enthought, Inc.
 
Scientific Computing with Python Webinar --- June 19, 2009
Scientific Computing with Python Webinar --- June 19, 2009Scientific Computing with Python Webinar --- June 19, 2009
Scientific Computing with Python Webinar --- June 19, 2009Enthought, Inc.
 
Scientific Computing with Python Webinar --- May 22, 2009
Scientific Computing with Python Webinar --- May 22, 2009Scientific Computing with Python Webinar --- May 22, 2009
Scientific Computing with Python Webinar --- May 22, 2009Enthought, Inc.
 

More from Enthought, Inc. (14)

Numpy Talk at SIAM
Numpy Talk at SIAMNumpy Talk at SIAM
Numpy Talk at SIAM
 
Talk at NYC Python Meetup Group
Talk at NYC Python Meetup GroupTalk at NYC Python Meetup Group
Talk at NYC Python Meetup Group
 
Scientific Applications with Python
Scientific Applications with PythonScientific Applications with Python
Scientific Applications with Python
 
SciPy 2010 Review
SciPy 2010 ReviewSciPy 2010 Review
SciPy 2010 Review
 
Scientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
Scientific Computing with Python Webinar March 19: 3D Visualization with MayaviScientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
Scientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
 
NumPy/SciPy Statistics
NumPy/SciPy StatisticsNumPy/SciPy Statistics
NumPy/SciPy Statistics
 
February EPD Webinar: How do I...use PiCloud for cloud computing?
February EPD Webinar: How do I...use PiCloud for cloud computing?February EPD Webinar: How do I...use PiCloud for cloud computing?
February EPD Webinar: How do I...use PiCloud for cloud computing?
 
SciPy India 2009
SciPy India 2009SciPy India 2009
SciPy India 2009
 
Parallel Processing with IPython
Parallel Processing with IPythonParallel Processing with IPython
Parallel Processing with IPython
 
Scientific Computing with Python Webinar: Traits
Scientific Computing with Python Webinar: TraitsScientific Computing with Python Webinar: Traits
Scientific Computing with Python Webinar: Traits
 
Scientific Computing with Python Webinar 9/18/2009:Curve Fitting
Scientific Computing with Python Webinar 9/18/2009:Curve FittingScientific Computing with Python Webinar 9/18/2009:Curve Fitting
Scientific Computing with Python Webinar 9/18/2009:Curve Fitting
 
Scientific Computing with Python Webinar --- August 28, 2009
Scientific Computing with Python Webinar --- August 28, 2009Scientific Computing with Python Webinar --- August 28, 2009
Scientific Computing with Python Webinar --- August 28, 2009
 
Scientific Computing with Python Webinar --- June 19, 2009
Scientific Computing with Python Webinar --- June 19, 2009Scientific Computing with Python Webinar --- June 19, 2009
Scientific Computing with Python Webinar --- June 19, 2009
 
Scientific Computing with Python Webinar --- May 22, 2009
Scientific Computing with Python Webinar --- May 22, 2009Scientific Computing with Python Webinar --- May 22, 2009
Scientific Computing with Python Webinar --- May 22, 2009
 

Chaco Step-by-Step

  • 1. Chaco step-by-step July 17, 2009 Monday, February 22, 2010
  • 3. Enthought Python Distribution (EPD) MORE THAN FIFTY INTEGRATED PACKAGES • Python 2.5.2 • Database (MySQL, SQLLite, etc.) • Science (NumPy, SciPy, etc.) • Data Storage (HDF, NetCDF, etc.) • Plotting (Chaco, Matplotlib) • Networking (twisted) • Visualization (VTK, Mayavi) • User Interface (wxPython, Traits UI) • Multi-language Integration • Enthought Tool Suite (SWIG,Pyrex, f2py, weave) (Application Development Tools) Monday, February 22, 2010
  • 4. Enthought Python Distribution (EPD) Monday, February 22, 2010
  • 5. Enthought Python Distribution (EPD) Selections from our training courses including: explanations, demonstrations, and tips For subscribers to Enthought Python Distribution (EPD) Offered once a month for 60-90 minutes depending on questions Monday, February 22, 2010
  • 6. Enthought Training Courses Python Basics, NumPy, SciPy, Matplotlib, Traits, TraitsUI, Chaco… Monday, February 22, 2010
  • 7. Upcoming Training Classes September 21 – 25, 2009 Introduction to Scientific Computing with Python Austin, Texas October 19 – 22, 2009 Python for Science, Eng., and Financial Analysis Silicon Valley, California November 9 – 12, 2009 Python for Science, Eng., and Financial Analysis Chicago, Illinois December 7 – 11, 2009 Introduction to Scientific Computing with Python Austin, Texas http://www.enthought.com/training/ Monday, February 22, 2010
  • 8. Enthought Tool Suite http://code.enthought.com/ Monday, February 22, 2010
  • 9. Rich Client App (Geophysics, Finance, Etc) Testing Framework Scripting Interface Data Display Equipment Compliance Scientific Database Chaco UI Interface Tools Algorithms Access Plotting Elements Monday, February 22, 2010
  • 12. Introduction • Chaco is a plotting application toolkit • You can build simple, static plots Monday, February 22, 2010
  • 13. Introduction • Chaco is a plotting application toolkit • You can build simple, static plots • You can also build rich, interactive visualizations: Monday, February 22, 2010
  • 14. “Script-oriented” Plotting • from numpy import * • from enthought.chaco.shell import * • x = linspace(-2*pi, 2*pi, 100) • y = sin(x) • plot(x, y, 'r-') • title('First plot') • ytitle('sin(x)') • show() Monday, February 22, 2010
  • 15. “Application-oriented” Plotting • class LinePlot(HasTraits): • plot = Instance(Plot) • traits_view = View( • Item('plot',editor=ComponentEditor(), • show_label=False), • width=500, height=500, • resizable=True, • title="Chaco Plot") • def __init__(self): • x = linspace(-14, 14, 100) • y = sin(x) * x**3 • plotdata = ArrayPlotData(x = x, y = y) • plot = Plot(plotdata) • plot.plot(("x", "y"), type="line", • color="blue") • plot.title = "sin(x) * x^3" • self.plot = plot • if __name__ == "__main__": • LinePlot().configure_traits() Monday, February 22, 2010
  • 16. First Plot class LinePlot(HasTraits): plot = Instance(Plot) traits_view = View( Item('plot', editor=ComponentEditor(), show_label=False), width=500, height=500, resizable=True, title="Chaco Plot") def __init__(self): x = linspace(-14, 14, 100) y = sin(x) * x**3 plotdata = ArrayPlotData(x = x, y = y) plot = Plot(plotdata) plot.plot(("x", "y"), type="line", color="blue") plot.title = "sin(x) * x^3" self.plot = plot Monday, February 22, 2010
  • 17. First Plot class LinePlot(HasTraits): plot = Instance(Plot) traits_view = View( Item('plot',editor=ComponentEditor(), show_label=False), width=500, height=500, resizable=True, title="Chaco Plot") def __init__(self): x = linspace(-14, 14, 100) y = sin(x) * x**3 plotdata = ArrayPlotData(x = x, y = y) plot = Plot(plotdata) plot.plot(("x", "y"), type="line", color="blue") plot.title = "sin(x) * x^3" self.plot = plot Monday, February 22, 2010
  • 18. First Plot class LinePlot(HasTraits): plot = Instance(Plot) traits_view = View( Item('plot',editor=ComponentEditor(), show_label=False), width=500, height=500, resizable=True, title="Chaco Plot") def __init__(self): x = linspace(-14, 14, 100) y = sin(x) * x**3 plotdata = ArrayPlotData(x = x, y = y) plot = Plot(plotdata) plot.plot(("x", "y"), type="line", color="blue") plot.title = "sin(x) * x^3" self.plot = plot Monday, February 22, 2010
  • 19. First Plot class LinePlot(HasTraits): plot = Instance(Plot) traits_view = View( Item('plot',editor=ComponentEditor(), show_label=False), width=500, height=500, resizable=True, title="Chaco Plot") def __init__(self): x = linspace(-14, 14, 100) y = sin(x) * x**3 plotdata = ArrayPlotData(x = x, y = y) plot = Plot(plotdata) plot.plot(("x", "y"), type="line", color="blue") plot.title = "sin(x) * x^3" self.plot = plot Monday, February 22, 2010
  • 20. First Plot class LinePlot(HasTraits): plot = Instance(Plot) traits_view = View( Item('plot',editor=ComponentEditor(), show_label=False), width=500, height=500, resizable=True, title="Chaco Plot") def __init__(self): x = linspace(-14, 14, 100) y = sin(x) * x**3 plotdata = ArrayPlotData(x = x, y = y) plot = Plot(plotdata) plot.plot(("x", "y"), type="line", color="blue") plot.title = "sin(x) * x^3" self.plot = plot Monday, February 22, 2010
  • 21. First Plot class LinePlot(HasTraits): plot = Instance(Plot) traits_view = View( Item('plot',editor=ComponentEditor(), show_label=False), width=500, height=500, resizable=True, title="Chaco Plot") def __init__(self): x = linspace(-14, 14, 100) y = sin(x) * x**3 plotdata = ArrayPlotData(x = x, y = y) plot = Plot(plotdata) plot.plot(("x", "y"), type="line", color="blue") plot.title = "sin(x) * x^3" self.plot = plot Monday, February 22, 2010
  • 22. First Plot class LinePlot(HasTraits): plot = Instance(Plot) traits_view = View( Item('plot',editor=ComponentEditor(), show_label=False), width=500, height=500, resizable=True, title="Chaco Plot") def __init__(self): x = linspace(-14, 14, 100) y = sin(x) * x**3 plotdata = ArrayPlotData(x = x, y = y) plot = Plot(plotdata) plot.plot(("x", "y"), type="line", color="blue") plot.title = "sin(x) * x^3" self.plot = plot Monday, February 22, 2010
  • 23. First Plot Finally, do something when this script is executed: if __name__ == "__main__": LinePlot().configure_traits() Monday, February 22, 2010
  • 24. Scatter Plot • class ScatterPlot(HasTraits): • plot = Instance(Plot) • traits_view = View( • Item('plot', editor=ComponentEditor(), • show_label=False), • width=500, height=500, • resizable=True, • title="Chaco Plot") • def __init__(self): • x = linspace(-14, 14, 100) • y = sin(x) * x**3 • plotdata = ArrayPlotData(x = x, y = y) • plot = Plot(plotdata) • plot.plot(("x", "y"), type="scatter", • color="blue") • self.plot = plot • if __name__ == "__main__": Monday, February 22, 2010
  • 25. Image Plot • class ImagePlot(HasTraits): • plot = Instance(Plot) • traits_view = View( • Item('plot', editor=ComponentEditor(), • show_label=False), • width=500, height=500, • resizable=True, • title=”Chaco Plot”) • def __init__(self): • x = linspace(0, 10, 50) • y = linspace(0, 5, 50) • xgrid, ygrid = meshgrid(x, y) • z = exp(-(xgrid*xgrid+ygrid*ygrid)/100) • plotdata = ArrayPlotData(imagedata = z) • plot = Plot(plotdata) • plot.img_plot("imagedata", xbounds=x, • ybounds=y, colormap=jet) • self.plot = plot • if __name__ == "__main__": • ImagePlot().configure_traits() Monday, February 22, 2010
  • 26. A Slight Modification • class OverlappingPlot(HasTraits): • plot = Instance(Plot) • traits_view = View( • Item('plot',editor=ComponentEditor(), • show_label=False), • width=500, height=500, • resizable=True, • title=”Chaco Plot”) • def __init__(self): • x = linspace(-14, 14, 100) • y = x/2 * sin(x) • y2 = cos(x) • plotdata = ArrayPlotData(x=x,y=y,y2=y2) • plot = Plot(plotdata) • plot.plot(("x", "y"), type="scatter", • color="blue") • plot.plot(("x", "y2"), type="line", • color="red") • self.plot = plot • if __name__ == "__main__": • OverlappingPlot().configure_traits() Monday, February 22, 2010
  • 27. Editing Plot Traits • from enthought.traits.api import Int • from enthought.enable.api import ColorTrait • from enthought.chaco.api import marker_trait • class ScatterPlotTraits(HasTraits): • plot = Instance(Plot) • color = ColorTrait("blue") • marker = marker_trait • marker_size = Int(4) Monday, February 22, 2010
  • 28. Editing Plot Traits • from enthought.traits.api import Int • from enthought.enable.api import ColorTrait • from enthought.chaco.api import marker_trait • class ScatterPlotTraits(HasTraits): • plot = Instance(Plot) • color = ColorTrait("blue") • marker = marker_trait • marker_size = Int(4) • traits_view = View( • Group( • Item('color', label="Color", style="custom"), • Item('marker', label="Marker"), • Item('marker_size', label="Size"), • Item('plot', editor=ComponentEditor(), • show_label=False), • orientation = "vertical" • ), • width=500, height=500, • resizable=True, • title="Chaco Plot") Monday, February 22, 2010
  • 29. Editing Plot Traits • def __init__(self): • • x = linspace(-14, 14, 100) • y = sin(x) * x**3 • plotdata = ArrayPlotData(x = x, y = y) • • plot = Plot(plotdata) • • self.renderer = plot.plot(("x", "y"), type="scatter", • color="blue")[0] • self.plot = plot Monday, February 22, 2010
  • 30. Editing Plot Traits • def __init__(self): • • x = linspace(-14, 14, 100) • y = sin(x) * x**3 • plotdata = ArrayPlotData(x = x, y = y) • • plot = Plot(plotdata) • • self.renderer = plot.plot(("x", "y"), type="scatter", • color="blue")[0] • self.plot = plot • def _color_changed(self): • self.renderer.color = self.color Monday, February 22, 2010
  • 31. Editing Plot Traits • def __init__(self): • • x = linspace(-14, 14, 100) • y = sin(x) * x**3 • plotdata = ArrayPlotData(x = x, y = y) • • plot = Plot(plotdata) • • self.renderer = plot.plot(("x", "y"), type="scatter", • color="blue")[0] • self.plot = plot • def _color_changed(self): • self.renderer.color = self.color • def _marker_changed(self): • self.renderer.marker = self.marker • def _marker_size_changed(self): • self.renderer.marker_size = self.marker_size Monday, February 22, 2010
  • 32. Editing Plot Traits Monday, February 22, 2010
  • 33. Tools from enthought.chaco.tools.api import PanTool, ZoomTool, DragZoom class ToolsExample(HasTraits): plot = Instance(Plot) traits_view = View( Item('plot',editor=ComponentEditor(), show_label=False), width=500, height=500, resizable=True, title="Chaco Plot") def __init__(self): x = linspace(-14, 14, 100) y = sin(x) * x**3 plotdata = ArrayPlotData(x = x, y = y) plot = Plot(plotdata) plot.plot(("x", "y"), type="line", color="blue") plot.tools.append(PanTool(plot)) plot.tools.append(ZoomTool(plot)) plot.tools.append(DragZoom(plot, drag_button="right")) self.plot = plot Monday, February 22, 2010
  • 34. Tool Chooser from enthought.traits.ui.api import CheckListEditor class ToolsExample(HasTraits): plot = Instance(Plot) tools = List(editor=CheckListEditor(values = ["PanTool", "SimpleZoom", "DragZoom"])) Monday, February 22, 2010
  • 35. Tool Chooser from enthought.traits.ui.api import CheckListEditor class ToolsExample(HasTraits): plot = Instance(Plot) tools = List(editor=CheckListEditor(values = ["PanTool", "SimpleZoom", "DragZoom"])) def __init__(self): x = linspace(-14, 14, 500) y = sin(x) * x**3 plotdata = ArrayPlotData(x = x, y = y) plot = Plot(plotdata) plot.plot(("x", "y"), type="line", color="blue") plot.tools.append(PanTool(plot)) plot.tools.append(ZoomTool(plot)) plot.tools.append(DragZoom(plot, drag_button="right")) self.plot = plot Monday, February 22, 2010
  • 36. Tool Chooser def _tools_changed(self): classes = [eval(class_name) for class_name in self.tools] for tool in self.plot.tools: if tool.__class__ not in classes: self.plot.tools.remove(tool) else: classes.remove(tool.__class__) for cls in classes: self.plot.tools.append(cls(self.plot)) return Monday, February 22, 2010
  • 37. Tool Chooser def _tools_changed(self): classes = [eval(class_name) for class_name in self.tools] for tool in self.plot.tools: if tool.__class__ not in classes: self.plot.tools.remove(tool) else: classes.remove(tool.__class__) for cls in classes: self.plot.tools.append(cls(self.plot)) return Monday, February 22, 2010
  • 38. Tool Chooser def _tools_changed(self): classes = [eval(class_name) for class_name in self.tools] for tool in self.plot.tools: if tool.__class__ not in classes: self.plot.tools.remove(tool) else: classes.remove(tool.__class__) for cls in classes: self.plot.tools.append(cls(self.plot)) return Monday, February 22, 2010
  • 39. Tool Chooser def _tools_changed(self): classes = [eval(class_name) for class_name in self.tools] for tool in self.plot.tools: if tool.__class__ not in classes: self.plot.tools.remove(tool) else: classes.remove(tool.__class__) for cls in classes: self.plot.tools.append(cls(self.plot)) return Monday, February 22, 2010
  • 40. Tool Chooser def _tools_changed(self): classes = [eval(class_name) for class_name in self.tools] for tool in self.plot.tools: if tool.__class__ not in classes: self.plot.tools.remove(tool) else: classes.remove(tool.__class__) for cls in classes: self.plot.tools.append(cls(self.plot)) return Monday, February 22, 2010
  • 41. Tool Chooser def _tools_changed(self): classes = [eval(class_name) for class_name in self.tools] for tool in self.plot.tools: if tool.__class__ not in classes: self.plot.tools.remove(tool) else: classes.remove(tool.__class__) for cls in classes: self.plot.tools.append(cls(self.plot)) return Monday, February 22, 2010
  • 42. Tool Chooser def _tools_changed(self): classes = [eval(class_name) for class_name in self.tools] for tool in self.plot.tools: if tool.__class__ not in classes: self.plot.tools.remove(tool) else: classes.remove(tool.__class__) for cls in classes: self.plot.tools.append(cls(self.plot)) return Monday, February 22, 2010
  • 43. Tool Chooser class ToolChooserExample(HasTraits): plot = Instance(Plot) tools = List(editor=CheckListEditor(values = ["PanTool", "ZoomTool", "DragZoom"])) traits_view = View(Item("tools", label="Tools", style="custom"), Item('plot', editor=ComponentEditor(), show_label=False), width=800, height=600, resizable=True, title="Tool Chooser") def __init__(self): ... def _tools_changed(self): classes = [eval(class_name) for class_name in self.tools] # Remove all tools that are not in the enabled list in self.tools for tool in self.plot.tools: if tool.__class__ not in classes: self.plot.tools.remove(tool) else: classes.remove(tool.__class__) # Create new instances of tools for the remaining tool classes for cls in classes: self.plot.tools.append(cls(self.plot)) return Monday, February 22, 2010
  • 45. Writing a Custom Tool from enthought.enable.api import BaseTool class CustomTool(BaseTool): def normal_mouse_move(self, event): print "Screen point:", event.x, event.y class ScatterPlot(HasTraits): plot = Instance(Plot) traits_view = View(Item('plot', editor=ComponentEditor(), show_label=False), width=800, height=600, resizable=True, title="Custom Tool") def _plot_default(self): x = linspace(-14, 14, 100) y = sin(x) * x**3 plotdata = ArrayPlotData(x = x, y = y) plot = Plot(plotdata) plot.plot(("x", "y"), type="scatter", color="blue") plot.tools.append(CustomTool(plot)) return plot Monday, February 22, 2010
  • 46. Writing a Custom Tool from enthought.enable.api import BaseTool class CustomTool(BaseTool): def normal_mouse_move(self, event): print "Screen point:", event.x, event.y class ScatterPlot(HasTraits): plot = Instance(Plot) traits_view = View(Item('plot', editor=ComponentEditor(), show_label=False), width=800, height=600, resizable=True, title="Custom Tool") def _plot_default(self): x = linspace(-14, 14, 100) y = sin(x) * x**3 plotdata = ArrayPlotData(x = x, y = y) plot = Plot(plotdata) plot.plot(("x", "y"), type="scatter", color="blue") plot.tools.append(CustomTool(plot)) return plot Monday, February 22, 2010
  • 47. Writing a Custom Tool from enthought.enable.api import BaseTool class CustomTool(BaseTool): def normal_mouse_move(self, event): print "Screen point:", event.x, event.y class ScatterPlot(HasTraits): plot = Instance(Plot) traits_view = View(Item('plot', editor=ComponentEditor(), show_label=False), width=800, height=600, resizable=True, title=”Custom Tool”) def _plot_default(self): x = linspace(-14, 14, 100) y = sin(x) * x**3 plotdata = ArrayPlotData(x = x, y = y) plot = Plot(plotdata) plot.plot(("x", "y"), type="scatter", color="blue") plot.tools.append(CustomTool(plot)) return plot Monday, February 22, 2010
  • 48. Writing a Custom Tool class CustomTool(BaseTool): def normal_mouse_move(self, event): print "Screen point:", event.x, event.y def normal_left_down(self, event): print "Mouse went down at", event.x, event.y def normal_left_up(self, event): print "Mouse went up at:", event.x, event.y Monday, February 22, 2010
  • 49. Writing a Custom Tool class CustomTool(BaseTool): event_state = Enum("normal", "mousedown") def normal_mouse_move(self, event): print "Screen:", event.x, event.y def normal_left_down(self, event): self.event_state = "mousedown" event.handled = True def mousedown_left_up(self, event): self.event_state = "normal" event.handled = True Monday, February 22, 2010
  • 50. Writing a Custom Tool class CustomTool(BaseTool): event_state = Enum("normal", "mousedown") def normal_mouse_move(self, event): print "Screen:", event.x, event.y def normal_left_down(self, event): self.event_state = "mousedown" event.handled = True def mousedown_mouse_move(self, event): print "Data:", self.component.map_data((event.x, event.y)) def mousedown_left_up(self, event): self.event_state = "normal" event.handled = True Monday, February 22, 2010
  • 51. Additional Tutorial Examples Custom Overlay Monday, February 22, 2010
  • 52. Additional Tutorial Examples Custom Overlay with Dataspace Option Monday, February 22, 2010
  • 53. More information • Web page: http://code.enthought.com/projects/chaco • Wiki: https://svn.enthought.com/enthought/wiki/ChacoProject • Gallery: http://code.enthought.com/projects/chaco/gallery.php • Mailing lists: enthought-dev@enthought.com, chaco-users@enthought.com Monday, February 22, 2010