File: twograftest2d.py

package info (click to toggle)
python-scipy 0.5.2-0.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 33,888 kB
  • ctags: 44,231
  • sloc: ansic: 156,256; cpp: 90,347; python: 89,604; fortran: 73,083; sh: 1,318; objc: 424; makefile: 342
file content (118 lines) | stat: -rw-r--r-- 3,915 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
## Automatically adapted for scipy Oct 31, 2005 by

# Copyright (c) 1996, 1997, The Regents of the University of California.
# All rights reserved.  See Legal.htm for full text and disclaimer.

from scipy import *
from numpy.core.umath import *
GraphicsError = "GraphicsError"

import os
try:
    graphics = os.environ["PYGRAPH"]
except KeyError:
    graphics = "Gist"

if graphics [0:3] == "Nar" :
    import NarPlotter
    gr = NarPlotter
    print "This is a test of the Python interface to the Limeil Lab graphics"
    print "package, Narcisse. You  need Narcisse to be running. Fire it up by"
    print "doing setenv PORT_SERVEUR 0, typing  /dist/basis/Narcisse/bin/Narcisse &,"
    print "and then do another senetv PORT_SERVEUR to the port number which"
    print "appears in the Narcisse GUI."
elif graphics == "Gist" :
    import GistPlotter
    gr = GistPlotter
    print "This is a test of the Python interface to the Gist graphics"
    print "package."
else :
    raise GraphicsError , \
       graphics + " is an unknown graphics package. Check PYGRAPH " + \
          "environment variable."

print "Test of 2D plotting routine. Type demo () to see the test."

from curve import Curve
from graph2d import *
def paws ( ) :
    i = raw_input ("Type in any string to continue; ^C to return to prompt. ")
    return

paws()

def demo () :

    vsf = 0.
    c = 1
    s = 1000.
    kmax = 25
    lmax = 35

    pl1 = gr.Plotter (" ")
    c1 = Curve ( y = arange (1, kmax+1, dtype = Float) , color = "yellow" )
    g2 = Graph2d ( c1 , plotter = [pl1], titles = ["Bottom of the Barrel", "Top Dog",
                                  "Leftist", "Reaganist"] )
    g2.plot ( )
    paws ( )
    c2 = Curve ( y = sqrt (arange (1, kmax+1, dtype = Float)**3) , color = "blue")
    g2.add ( c2 )
    g2.plot ( )
    paws ( )
    c1.set (marks = 1, marker = "A")
    c2.set (marks = 1, marker = "B")
    g2.plot ( )
    paws ( )
    c1.set (marks = 0)
    c2.set (marks = 0)
    c1.set (width = 3.0)
    c2.set (width = 4.0)
    g2.plot ( )
    paws ( )
    c1.set (type = "dash")
    c2.set (type = "dashdot")
    g2.plot ( )
    paws ( )
    g2.delete ( 1 )
    g2.plot ( )
    paws ( )
    mycolor= ["red", "blue", "yellow", "green", "orange", "purple"]
    markers= ["+", "*", "o", "x", "."]
    c5 = [ ]
    for i in range (len (markers)) :
        c5.append ( Curve (
           y = exp (array (multiply ((1.0+(i+1)/10.), log (range (1, kmax))))) ,
                    color = mycolor [i] , marks = 1, marker = markers [i] ,
                    type = "none" )
                  )
    g2.new ( c5 , text="Line style and grid test" , text_color="black" ,
              plotter = [pl1],
              text_pos = array ( [.2, .8]) , text_size = 60 ,
              titles = "Figure 1")
    g2.plot ( )
    paws ( )
    g2.quick_plot ( grid_type = "wide" )
    paws ( )
    part1 = abs (array ( [-5, -4, -3, -2, -1, .0000000001] ) )
    c1.new (  y = part1, x = arange (-5, 1, dtype = Float) ,
             type="line" , color = "blue" )
    part2 = array ( [.0000000001, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] )
    c2.new ( y = part2 , x = arange (0, 11, dtype = Float) ,
             type = "line" , color = "blue" )
    g2.new ( [c1, c2] , text = " " , axis_scales = "linlog" , titles = " " ,
              old_plotter = 1,
              axis_limits = array ( [[-6., 10.], [1.e-6, 10.]]))
    g2.plot ( )
    paws ( )
    c1.new ( y = array (exp (multiply (log (10.0), range (-50, 1)))) ,
             x = arange (1, 52, dtype = Float) )
    g2.new ( c1 , axis_scales = "loglog" ,
              old_plotter = 1,
                  axis_limits = array ( [[1., 100.], [1.e-8, 1.]]))
    g2.plot ( )
    paws ( )
    c1.new ( y = array ( [1.e-48, 1.e-21, 0., 0., 0.]) )
    g2.new ( c1 , axis_scales = "linlin" ,
              old_plotter = 1,
                  axis_limits = array  ( [[0., 0.], [0., 0.]]))
    g2.plot ( )