~ubuntu-branches/ubuntu/intrepid/python-gnuplot/intrepid

« back to all changes in this revision

Viewing changes to demo.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2008-06-24 18:40:22 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080624184022-lnok0v9ja8uzdj82
Tags: 1.8-1
* New upstream version.
  - doc file with broken link not shipped anymore. Closes: #336422.
  - Use `with_' instead of `with', which is a keyword in python2.6.
    Closes: #424965.
* Use python-numpy instead of python-numeric. Closes: #469313, #478468.
* Update watch file. Closes: #450271.
* Register documention in section `Programming/Python'.
* Update datafile.py.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /usr/bin/env python
2
 
# $Id: demo.py,v 2.10 2003/04/21 09:44:09 mhagger Exp $
 
2
# $Id: demo.py 299 2007-03-30 12:52:17Z mhagger $
3
3
 
4
4
# Copyright (C) 1999-2003 Michael Haggerty <mhagger@alum.mit.edu>
5
5
#
13
13
 
14
14
"""
15
15
 
16
 
__cvs_version__ = '$Revision: 2.10 $'
17
 
 
18
 
 
19
 
from Numeric import *
 
16
from numpy import *
20
17
 
21
18
# If the package has been installed correctly, this should work:
22
19
import Gnuplot, Gnuplot.funcutils
31
28
    g = Gnuplot.Gnuplot(debug=1)
32
29
    g.title('A simple example') # (optional)
33
30
    g('set data style linespoints') # give gnuplot an arbitrary command
34
 
    # Plot a list of (x, y) pairs (tuples or a Numeric array would
 
31
    # Plot a list of (x, y) pairs (tuples or a numpy array would
35
32
    # also be OK):
36
33
    g.plot([[0,1.1], [1,5.8], [2,3.3], [3,4.2]])
37
34
    raw_input('Please press return to continue...\n')
39
36
    g.reset()
40
37
    # Plot one dataset from an array and one via a gnuplot function;
41
38
    # also demonstrate the use of item-specific options:
42
 
    x = arange(10, typecode=Float)
 
39
    x = arange(10, dtype='float_')
43
40
    y1 = x**2
44
41
    # Notice how this plotitem is created here but used later?  This
45
42
    # is convenient if the same dataset has to be plotted multiple
47
44
    # written to a temporary file once.
48
45
    d = Gnuplot.Data(x, y1,
49
46
                     title='calculated by python',
50
 
                     with='points 3 3')
 
47
                     with_='points 3 3')
51
48
    g.title('Data can be computed by python or gnuplot')
52
49
    g.xlabel('x')
53
50
    g.ylabel('x squared')
74
71
    # Make a 2-d array containing a function of x and y.  First create
75
72
    # xm and ym which contain the x and y values in a matrix form that
76
73
    # can be `broadcast' into a matrix of the appropriate shape:
77
 
    xm = x[:,NewAxis]
78
 
    ym = y[NewAxis,:]
 
74
    xm = x[:,newaxis]
 
75
    ym = y[newaxis,:]
79
76
    m = (sin(xm) + 0.1*xm) - ym**2
80
77
    g('set parametric')
81
78
    g('set data style lines')