~ubuntu-branches/ubuntu/precise/python-chaco/precise

« back to all changes in this revision

Viewing changes to docs/source/quickstart.rst

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2008-12-29 02:34:05 UTC
  • Revision ID: james.westby@ubuntu.com-20081229023405-x7i4kp9mdxzmdnvu
Tags: upstream-3.0.1
ImportĀ upstreamĀ versionĀ 3.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
##########
 
2
Quickstart
 
3
##########
 
4
 
 
5
This section is meant to help users on well-supported platforms and common
 
6
Python environments get started using Chaco as quickly as possible.  If your
 
7
platform is not listed here, or your Python installation has some quirks, then
 
8
some of the following instructions might not work for you.  If you encounter
 
9
any problems in the steps below, please refer to the :ref:`installation`
 
10
section for more detailed instructions.
 
11
 
 
12
Installation Overview
 
13
=====================
 
14
 
 
15
There are several different ways to get Chaco:
 
16
 
 
17
* Install the Enthought Python Distribution.
 
18
  Chaco and the rest of the Enthought Tool Suite are bundled with it.  Go to
 
19
  the main `Enthought Python Distribution (EPD)
 
20
  <http://www.enthought.com/epd>`_ web site and download the appropriate
 
21
  version for your platform.  After running the installer, you will have a
 
22
  working version of Chaco.
 
23
  
 
24
  *Available platforms:* 
 
25
  
 
26
  * Windows 32-bit
 
27
  * Mac OS X 10.4 and 10.5
 
28
  * RedHat Enterprise Linux 3 (32-bit and 64-bit)
 
29
 
 
30
  .. note::
 
31
     Enthought Python Distribution is free for academic and personal
 
32
     use, and fee-based for commercial and government use.
 
33
 
 
34
* *(Windows, Mac)* Install from PyPI using easy_install (part of setuptools)
 
35
  from the command line:
 
36
 
 
37
  :command:`easy_install Chaco`
 
38
 
 
39
* *(Linux)* Install distribution-specific eggs from Enthought's repository.
 
40
  See the `ETS wiki <https://svn.enthought.com/enthought/wiki/Install#UsingEnthoughtsEggRepo>`_
 
41
  for instructions for installing pre-built binary eggs for your specific
 
42
  distribution of Linux.
 
43
 
 
44
* *(Linux)* Install via the distribution's packaging mechanism.  We provide
 
45
  .debs for Debian and Ubuntu and .rpms for Redhat.  (TODO)
 
46
 
 
47
* Download source as tarballs or from Subversion and build.  See 
 
48
  the :ref:`installation` section.
 
49
 
 
50
Chaco requires Python version 2.5.
 
51
 
 
52
 
 
53
 
 
54
Running Some Examples
 
55
=====================
 
56
 
 
57
Depending on how you installed Chaco, you may or may not have the examples already.
 
58
 
 
59
If you installed Chaco as part of EPD, the location of the examples depends on 
 
60
your platform:
 
61
 
 
62
* On Windows, they are in the :file:`Examples\\` subdirectory of your installation
 
63
  location.  This is typically :file:`C:\\Python25\\Examples`.
 
64
 
 
65
* On Linux, they are in the :file:`Examples/` subdirectory of your installation
 
66
  location.
 
67
 
 
68
* On Mac OS X, they are in the :file:`/Applications/<EPD Version>/Examples/`
 
69
  directory.
 
70
 
 
71
If you downloaded and installed Chaco from source (via the PyPI tar.gz file, or
 
72
from an SVN checkout), the examples are located in the :file:`examples/` subdirectory
 
73
inside the root of the Chaco source tree, next to :file:`docs/` and the :file:`enthought/`
 
74
directories.
 
75
 
 
76
If you installed Chaco as a binary egg from PyPI for your platform, or if you
 
77
happen to be on a machine with Chaco installed, but you don't know the exact
 
78
installation mechanism, then you will need to download the examples separately
 
79
using Subversion:
 
80
 
 
81
* ETS 3.0 or Chaco 3.0:
 
82
  
 
83
  :command:`svn co https://svn.enthought.com/svn/enthought/Chaco/tags/3.0.0/examples`
 
84
 
 
85
* ETS 2.8 or Chaco 2.0.x:
 
86
  
 
87
  :command:`svn co https://svn.enthought.com/svn/enthought/Chaco/tags/enthought.chaco2_2.0.5/examples`
 
88
 
 
89
.. [COMMENT]::
 
90
    (TODO):  Add links to examples tarball.
 
91
 
 
92
Almost all of the Chaco examples are stand-alone files that can be run
 
93
individually, from any location.
 
94
 
 
95
All of the following instructions that involve the command line assume that 
 
96
you are in the same directory as the examples.
 
97
 
 
98
Command line
 
99
------------
 
100
 
 
101
Run the ``simple_line`` example:
 
102
 
 
103
    :command:`python simple_line.py`
 
104
 
 
105
This opens a plot of several Bessel functions and a legend.
 
106
 
 
107
.. image:: images/simple_line.png
 
108
 
 
109
You can interact with the plot in several ways:
 
110
 
 
111
* To pan the plot, hold down the left mouse button inside the plot area
 
112
  (but not on the legend) and drag the mouse.
 
113
 
 
114
* To zoom the plot:
 
115
 
 
116
    * Mouse wheel: scroll up to zoom in, and scroll down to zoom out.
 
117
    
 
118
    * Zoom box: Press "z", and then draw a box region to zoom in on. (There
 
119
      is no box-based zoom out.) Press Ctrl-Left and Ctrl-Right to go
 
120
      back and forward in your zoom box history.
 
121
    
 
122
    * Drag: hold down the right mouse button and drag the mouse up
 
123
      or down. Up zooms in, and down zooms out.
 
124
    
 
125
    * For any of the above, press Escape to resets the zoom to the
 
126
      original view.
 
127
 
 
128
* To move the legend, hold down the right mouse button inside the
 
129
  legend and drag it around. Note that you can move the legend
 
130
  outside of the plot area.
 
131
 
 
132
* To exit the plot, click the "close window" button on the window frame
 
133
  (Windows, Linux) or choose the Quit option on the Python menu (on
 
134
  Mac).  Alternatively, can you press Ctrl-C in the terminal.
 
135
 
 
136
You can run most of the examples in the top-level :file:`examples`
 
137
directory, the :file:`examples/basic/` directory, and the :file:`examples/shell/`
 
138
directory.  The :file:`examples/advanced/` directory has some examples that
 
139
may or may not work on your system:
 
140
 
 
141
* :file:`spectrum.py` requires that you have PyAudio installed and a working
 
142
  microphone.  
 
143
 
 
144
* :file:`data_cube.py` needs to download about 7.3mb of data from the Internet
 
145
  the first time it is executed, so you must have a working
 
146
  Internet connection. Once the data is downloaded, you can save it so you 
 
147
  can run the example offline in the future.
 
148
 
 
149
For detailed information about each built-in example, see the :ref:`examples`
 
150
section.
 
151
 
 
152
IPython
 
153
-------
 
154
 
 
155
While all of the Chaco examples can be launched from the command line using the
 
156
standard Python interpreter, if you have IPython installed, you can poke around
 
157
them in a more interactive fashion.
 
158
 
 
159
Chaco provides a subpackage, currently named the "Chaco Shell", for doing
 
160
command-line plotting like Matlab or Matplotlib.  The examples in the
 
161
:file:`examples/shell/` directory use this subpackage, and they are particularly
 
162
amenable to exploration with IPython.
 
163
 
 
164
The first example we'll look at is the :file:`lines.py` example.  First, we'll
 
165
run it using the standard Python interpreter:
 
166
 
 
167
    :command:`python lines.py`
 
168
 
 
169
This shows two overlapping line plots.
 
170
 
 
171
.. image:: images/lines.png
 
172
 
 
173
You can interact with the plot in the following ways:
 
174
 
 
175
    * To pan the plot, hold down the left mouse button inside the plot area
 
176
      and dragging the mouse.
 
177
 
 
178
    * To zoom the plot:
 
179
 
 
180
        * Mouse wheel: scroll up zooms in, and scroll down zooms out.
 
181
 
 
182
        * Zoom box: hold down the right mouse button, and then draw a box region
 
183
          to zoom in on.  (There is no box-based zoom out.)  Press Ctrl-Left and
 
184
          Ctrl-Right to go back and forward in your zoom box history.
 
185
        
 
186
        * For either of the above, press Escape to reset the zoom to the
 
187
          original view.
 
188
 
 
189
Now exit the plot, and start IPython with the -wthread option:
 
190
 
 
191
    :command:`ipython -wthread`
 
192
 
 
193
This tells IPython to start a wxPython mainloop in a background thread.  Now
 
194
run the previous example again::
 
195
 
 
196
    In [1]: run lines.py
 
197
 
 
198
This displays the plot window, but gives you another
 
199
IPython prompt.  You can now use various commands from the :mod:`chaco.shell`
 
200
package to interact with the plot.  
 
201
 
 
202
* Import the shell commands::
 
203
 
 
204
    In [2]: from enthought.chaco.shell import *
 
205
 
 
206
* Set the X-axis title::
 
207
 
 
208
    In [3]: xtitle("X data")
 
209
 
 
210
* Toggle the legend::
 
211
 
 
212
    In [4]: legend()
 
213
 
 
214
After running these commands, your plot looks like this:
 
215
 
 
216
.. image:: images/lines_final.png
 
217
 
 
218
The :func:`chaco_commands` function display a list of commands with brief
 
219
descriptions.
 
220
 
 
221
You can explore the Chaco object hierarchy, as well. The :mod:`chaco.shell` 
 
222
commands are just convenience functions that wrap a rich object hierarchy
 
223
that comprise the actual plot. See the :ref:`tutorial_ipython` section
 
224
for information on more complex and interesting things you can do with Chaco
 
225
from within IPython.
 
226
 
 
227
 
 
228
Start Menu (MS Windows)
 
229
-----------------------
 
230
 
 
231
If you installed the Enthought Python Distribution (EPD), you have
 
232
shortcuts installed in your Start Menu for many of the Chaco examples.  You can
 
233
run them by just clicking the shortcut.  (This just invokes python.exe on the
 
234
example file itself.)
 
235
 
 
236
 
 
237
Creating a Plot
 
238
===============
 
239
 
 
240
(TODO)
 
241
 
 
242
 
 
243
Further Reading
 
244
===============
 
245
 
 
246
Once you have Chaco installed, you can either visit the :ref:`tutorials`
 
247
to learn how to use the package, or you can run the examples (see the
 
248
:ref:`examples` section).
 
249
 
 
250
 
 
251
Presentations
 
252
-------------
 
253
 
 
254
There have been several presentations on Chaco at previous PyCon and 
 
255
SciPy conferences.  Slides and demos from these are described below.
 
256
 
 
257
Currently, the examples and the scipy 2006 tutorial are the best ways  
 
258
to get going quickly. (See http://code.enthought.com/projects/files/chaco_scipy06/chaco_talk.html)
 
259
 
 
260
Some tutorial examples were recently added into the examples/tutorials/scipy2008/  
 
261
directory on the trunk.  These examples are numbered and introduce  
 
262
concepts one at a time, going from a simple line plot to building a  
 
263
custom overlay with its own trait editor and reusing an existing tool  
 
264
from the built-in set of tools.  You can browse them on our SVN server  
 
265
at:
 
266
https://svn.enthought.com/enthought/browser/Chaco/trunk/examples/tutorials/scipy2008
 
267
 
 
268
.. _api_docs:
 
269
 
 
270
API Docs
 
271
--------
 
272
 
 
273
The API docs for Chaco 3.0 (in ETS 3.0) are at:
 
274
http://code.enthought.com/projects/files/ETS3_API/enthought.chaco.html
 
275
 
 
276
The API docs for Chaco2 (in ETS 2.7.1) are at:
 
277
http://code.enthought.com/projects/files/ets_api/enthought.chaco2.html
 
278
 
 
279