File: twograftest2d.py

package info (click to toggle)
python-scipy 0.3.2-6
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 13,572 kB
  • ctags: 20,326
  • sloc: ansic: 87,138; fortran: 51,876; python: 47,747; cpp: 2,134; objc: 384; makefile: 175; sh: 83
file content (115 lines) | stat: -rw-r--r-- 3,800 bytes parent folder | download
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
# Copyright (c) 1996, 1997, The Regents of the University of California.
# All rights reserved.  See Legal.htm for full text and disclaimer.

from Numeric import *
from scipy_base.fastumath 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."
paws ()

from curve import Curve
from graph2d import *
def paws ( ) :
    i = raw_input ("Type in any string to continue; ^C to return to prompt. ")
    return
 
def demo () :
    
   vsf = 0.
   c = 1
   s = 1000.
   kmax = 25
   lmax = 35
    
   pl1 = gr.Plotter (" ")
   c1 = Curve ( y = arange (1, kmax+1, typecode = 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, typecode = 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, typecode = 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, typecode = 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, typecode = 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 ( )