diff --git a/docs/source/user_manual/annotated_examples.rst b/docs/source/user_manual/annotated_examples.rst index 3c7bc278c..f71a6312c 100644 --- a/docs/source/user_manual/annotated_examples.rst +++ b/docs/source/user_manual/annotated_examples.rst @@ -110,9 +110,9 @@ source: `multiaxis.py `_ @@ -379,7 +379,7 @@ source: `polygon_plot_demo.py `_ @@ -428,7 +428,7 @@ source: `scatter_select.py Just curious. What are the pros and cons of chaco vs matplotlib? - - You had to go and ask, didn't you? :) There are many more folks here - who have used MPL more extensively than myself, so I'll defer the - comparisons to them. (Gael, as always, thanks for your comments and + + You had to go and ask, didn't you? :) There are many more folks here + who have used MPL more extensively than myself, so I'll defer the + comparisons to them. (Gael, as always, thanks for your comments and feedback!) I can comment, however, on the key goals of Chaco. - Chaco is a plotting toolkit targeted towards developers for building - interactive visualizations. You hook up pieces to build a plot that - is then easy to inspect, interact with, add configuration UIs for - (using Traits UI), etc. The layout of plot areas, the multiplicity - and types of renderers within those windows, the appearance and - locations of axes, etc. are all completely configurable since these - are all first-class objects participating in a visual canvas. They - can all receive mouse and keyboard events, and it's easy to subclass - them (or attach tools to them) to achieve new kinds of behavior. - We've tried to make all the plot renderers adhere to a standard - interface, so that tools and interactors can easily inspect data and - map between screen space and data space. Once these are all hooked + Chaco is a plotting toolkit targeted towards developers for building + interactive visualizations. You hook up pieces to build a plot that + is then easy to inspect, interact with, add configuration UIs for + (using Traits UI), etc. The layout of plot areas, the multiplicity + and types of renderers within those windows, the appearance and + locations of axes, etc. are all completely configurable since these + are all first-class objects participating in a visual canvas. They + can all receive mouse and keyboard events, and it's easy to subclass + them (or attach tools to them) to achieve new kinds of behavior. + We've tried to make all the plot renderers adhere to a standard + interface, so that tools and interactors can easily inspect data and + map between screen space and data space. Once these are all hooked up, you can swap out or update the data independently of the plots. - One of the downsides we had a for a while was that this rich set of - objects required the programmer to put several different classes - together just to make a basic plot. To solve this problem, we've - assembled some higher-level classes that have the most common - behaviors built-in by default, but which can still be easily - customized or extended. It's clear to me that this is a good general + One of the downsides we had a for a while was that this rich set of + objects required the programmer to put several different classes + together just to make a basic plot. To solve this problem, we've + assembled some higher-level classes that have the most common + behaviors built-in by default, but which can still be easily + customized or extended. It's clear to me that this is a good general approach to preserving flexibility while reducing verbosity. - At this point, Chaco is definitely capable of handling a large number - of different plotting tasks, and a lot of them don't require too much - typing or hacking skills. (Folks will probably require more - documentation, however, but I'm working on that. :) I linked to the - source for all of the screenshots in the gallery to demonstrate that - you can do a lot of things with Chaco in a few dozen lines of code. - (For instance, the audio spectrogram at the bottom of the gallery is + At this point, Chaco is definitely capable of handling a large number + of different plotting tasks, and a lot of them don't require too much + typing or hacking skills. (Folks will probably require more + documentation, however, but I'm working on that. :) I linked to the + source for all of the screenshots in the gallery to demonstrate that + you can do a lot of things with Chaco in a few dozen lines of code. + (For instance, the audio spectrogram at the bottom of the gallery is just a little over 100 lines.) - Fundamentally, I like the Chaco model of plots as compositions of - interactive components. This really helps me think about - visualization apps in a modular way, and it "fits my head". (Of - course, the fact that I wrote much of it might have something to do - with that as well. ;) The goal is to have data-related operations - clearly happen in one set of objects, the view layout and - configuration happen in another, and the interaction controls fit - neatly into a third. IMHO a good toolkit should help me design/ - architect my application better, and we definitely aspire to make + Fundamentally, I like the Chaco model of plots as compositions of + interactive components. This really helps me think about + visualization apps in a modular way, and it "fits my head". (Of + course, the fact that I wrote much of it might have something to do + with that as well. ;) The goal is to have data-related operations + clearly happen in one set of objects, the view layout and + configuration happen in another, and the interaction controls fit + neatly into a third. IMHO a good toolkit should help me design/ + architect my application better, and we definitely aspire to make Chaco meet that criterion. - Finally, one major perk is that since Chaco is built completely on - top of traits and its event-based component model, you can call - edit_traits() on any visual component from within your app (or - ipython) and get a live GUI that lets you tweak all of its various - parameters in realtime. This applies to the axis, grid, renderers, - etc. This seems so natural to me that I sometimes forget what an - awesome feature it is. :) + Finally, one major perk is that since Chaco is built completely on + top of traits and its event-based component model, you can call + edit_traits() on any visual component from within your app (or + ipython) and get a live GUI that lets you tweak all of its various + parameters in realtime. This applies to the axis, grid, renderers, + etc. This seems so natural to me that I sometimes forget what an + awesome feature it is. :) diff --git a/docs/source/user_manual/tutorial_hyetograph.rst b/docs/source/user_manual/tutorial_hyetograph.rst index f238b5f99..b357e2064 100644 --- a/docs/source/user_manual/tutorial_hyetograph.rst +++ b/docs/source/user_manual/tutorial_hyetograph.rst @@ -1,3 +1,4 @@ +:orphan: .. _tutorial_hyetograph: @@ -112,7 +113,7 @@ The above code snippet shows a number of Traits features, The Traits API Reference contains more information about the standard Trait types; see the :mod:`trait_types` module in the `Traits API Reference -`_. +`_. Setting up the User Interface (UI) diff --git a/docs/source/user_manual/tutorial_ipython.rst b/docs/source/user_manual/tutorial_ipython.rst index 040f4f79f..3e1b58bec 100644 --- a/docs/source/user_manual/tutorial_ipython.rst +++ b/docs/source/user_manual/tutorial_ipython.rst @@ -1,3 +1,4 @@ +:orphan: .. _tutorial_ipython: diff --git a/docs/source/user_manual/tutorial_van_der_waal.rst b/docs/source/user_manual/tutorial_van_der_waal.rst index 7cbcffbd3..dbf8bbbe1 100644 --- a/docs/source/user_manual/tutorial_van_der_waal.rst +++ b/docs/source/user_manual/tutorial_van_der_waal.rst @@ -1,3 +1,4 @@ +:orphan: .. _tutorial_van_der_waal: @@ -18,12 +19,11 @@ molecules and the attraction to each other that they experience. Development Setup ================= -In review, Traits is a manifest typing and reactive programming package for -Python. It also provides UI features that will be used to create a simple GUI. -The Traits and Traits UI user manuals are good resources for learning about the -packages and can be found on the -`Traits Wiki `_. The wiki -includes features, technical notes, cookbooks, FAQ and more. +In review, Traits is a manifest typing and reactive programming package +for Python. It also provides UI features that will be used to create a +simple GUI. The `Traits `_ and +`Traits UI `_ user manuals are good +resources for learning about the packages. You must have Chaco and its dependencies installed: @@ -37,10 +37,10 @@ Writing the Program First, define a Traits class and the elements necessary need to model the task. The following Traits class is made for the Van Der Waal -equation, whose variables can be viewed on +equation, whose variables can be viewed on `this wiki page `_. The -:attr:`volume` and :attr:`pressure` attributes hold lists of our X- and -Y-coordinates, respectively, and are defined as arrays. The attributes +:attr:`volume` and :attr:`pressure` attributes hold lists of our X- and +Y-coordinates, respectively, and are defined as arrays. The attributes :attr:`attraction` and :attr:`totVolume` are input parameters specified by the user. The type of the variables dictates their appearance in the GUI. For example, :attr:`attraction` and :attr:`totVolume` are defined as Ranges, so they @@ -52,10 +52,10 @@ list, since it is defined as an Enum. # We'll also import a few things to be used later. from traits.api \ import HasTraits, Array, Range, Float, Enum, on_trait_change, Property - from traitsui.api import View, Item + from traitsui.api import View, Item from chaco.chaco_plot_editor import ChacoPlotItem from numpy import arange - + class Data(HasTraits): volume = Array pressure = Array @@ -64,8 +64,8 @@ list, since it is defined as an Enum. temperature = Range(low=-50.0,high=50.0,value=50.0) r_constant= Float(8.314472) plot_type = Enum("line", "scatter") - - .... + + .... Creating the View @@ -75,7 +75,7 @@ The main GUI window is created by defining a Traits :class:`View` instance. This View contains all of the GUI elements, including the plot. To link a variable with a widget element on the GUI, we create a Traits :class:`Item` instance with the same name as the variable and pass it as an -argument of the Traits View instance declaration. The +argument of the Traits View instance declaration. The `Traits UI User Guide `_ discusses the View and Item objects in depth. In order to embed a Chaco plot into a Traits View, you need to import the @@ -88,7 +88,7 @@ provided to the plot for additional customization:: class Data(HasTraits): .... - + traits_view = View(ChacoPlotItem("volume", "pressure", type_trait="plot_type", resizable=True, @@ -106,7 +106,7 @@ provided to the plot for additional customization:: padding_bg_color="lightgray"), Item(name='attraction'), Item(name='totVolume'), - Item(name='temperature'), + Item(name='temperature'), Item(name='r_constant', style='readonly'), Item(name='plot_type'), resizable = True, @@ -115,7 +115,7 @@ provided to the plot for additional customization:: width=900, height=800) .... - + Updating the Plot ================= @@ -127,7 +127,7 @@ parameters are changed by the user moving the sliders in the GUI. The :attr:`volume` attribute is the independent variable and :attr:`pressure` is the dependent variable. The relationship between pressure and volume, as derived from the equation found on the wiki page, is:: - + r_constant * Temperature attraction Pressure = ------------------------ - ---------- Volume - totVolume Volume**2 @@ -149,15 +149,15 @@ The following is the code for these two needs:: def calc(self): """ Update the data based on the numbers specified by the user. """ self.volume = arange(.1, 100) - self.pressure = ((self.r_constant*self.temperature) - /(self.volume - self.totVolume) + self.pressure = ((self.r_constant*self.temperature) + /(self.volume - self.totVolume) -(self.attraction/(self.volume*self.volume))) return The :func:`calc` function computes the :attr:`pressure` array using the current values of the independent variables. Meanwhile, the :func:`@on_trait_change` decorator (provided by Traits) tells Python to call -:func:`calc` whenever any of the attributes :attr:`attraction`, +:func:`calc` whenever any of the attributes :attr:`attraction`, :attr:`totVolume`, or :attr:`temperature` changes. @@ -224,36 +224,36 @@ For the new implementation, these are the necessary changes: 1. Define the Y-coordinate array variable as a Property instead of an Array. -2. Perform the calculations in the :samp:`\_get_{trait_name}` method for the - Y-coordinate array variable, which is :meth:`_get_pressure` in this +2. Perform the calculations in the :samp:`\_get_{trait_name}` method for the + Y-coordinate array variable, which is :meth:`_get_pressure` in this example. 3. Define the :samp:`\_{trait}_default` method to set the initial value of - the X-coordinate array, so :meth:`\_get_pressure` does not have to keep + the X-coordinate array, so :meth:`\_get_pressure` does not have to keep recalculating it. -4. Remove the previous :func:`@on_trait_change` decorator and calculation +4. Remove the previous :func:`@on_trait_change` decorator and calculation method. The new pieces of code to add to the Data class are:: class Data(HasTraits): ... - pressure = Property(Array, depends_on=['temperature', - 'attraction', + pressure = Property(Array, depends_on=['temperature', + 'attraction', 'totVolume']) ... - + def _volume_default(self): return arange(.1, 100) - - # Pressure is recalculated whenever one of the elements the property + + # Pressure is recalculated whenever one of the elements the property # depends on changes. No need to use @on_trait_change. def _get_pressure(self): return ((self.r_constant*self.temperature) - /(self.volume - self.totVolume) + /(self.volume - self.totVolume) -(self.attraction/(self.volume*self.volume))) You now no longer have to call an inconvenient calculation function -before the first call to :meth:`configure_traits`! +before the first call to :meth:`configure_traits`! Source Code @@ -266,17 +266,17 @@ The final version on the program, `vanderwaals.py` :: from traitsui.api import View, Item from chaco.chaco_plot_editor import ChacoPlotItem from numpy import arange - + class Data(HasTraits): volume = Array - pressure = Property(Array, depends_on=['temperature', 'attraction', + pressure = Property(Array, depends_on=['temperature', 'attraction', 'totVolume']) attraction = Range(low=-50.0,high=50.0,value=0.0) totVolume = Range(low=.01,high=100.0,value=0.01) temperature = Range(low=-50.0,high=50.0,value=50.0) r_constant= Float(8.314472) plot_type = Enum("line", "scatter") - + traits_view = View(ChacoPlotItem("volume", "pressure", type_trait="plot_type", resizable=True, @@ -294,25 +294,25 @@ The final version on the program, `vanderwaals.py` :: padding_bg_color="lightgray"), Item(name='attraction'), Item(name='totVolume'), - Item(name='temperature'), + Item(name='temperature'), Item(name='r_constant', style='readonly'), Item(name='plot_type'), resizable = True, buttons = ["OK"], title='Van der Waal Equation', width=900, height=800) - - + + def _volume_default(self): """ Default handler for volume Trait Array. """ return arange(.1, 100) - + def _get_pressure(self): """Recalculate when one a trait the property depends on changes.""" return ((self.r_constant*self.temperature) - /(self.volume - self.totVolume) + /(self.volume - self.totVolume) -(self.attraction/(self.volume*self.volume))) - + if __name__ == '__main__': viewer = Data() viewer.configure_traits() diff --git a/docs/source/user_manual/tutorial_wx.rst b/docs/source/user_manual/tutorial_wx.rst deleted file mode 100644 index 7ebe785ef..000000000 --- a/docs/source/user_manual/tutorial_wx.rst +++ /dev/null @@ -1,9 +0,0 @@ - -.. _tutorial_wx: - -################# -WX-based Tutorial -################# - - - diff --git a/docs/source/user_manual/tutorials_and_examples.rst b/docs/source/user_manual/tutorials_and_examples.rst index 38ae93deb..ace2ea303 100644 --- a/docs/source/user_manual/tutorials_and_examples.rst +++ b/docs/source/user_manual/tutorials_and_examples.rst @@ -1,8 +1,8 @@ .. _tutorials: -Tutorials, webinars, and examples -================================= +Tutorials and examples +======================= Tutorials ---------