~ubuntu-branches/ubuntu/intrepid/plplot/intrepid

« back to all changes in this revision

Viewing changes to examples/python/xw23.py

  • Committer: Bazaar Package Importer
  • Author(s): Rafael Laboissiere
  • Date: 2006-11-04 10:19:34 UTC
  • mfrom: (2.1.8 edgy)
  • Revision ID: james.westby@ubuntu.com-20061104101934-mlirvdg4gpwi6i5q
Tags: 5.6.1-10
* Orphaning the package
* debian/control: Changed the maintainer to the Debian QA Group

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from Numeric import *
 
2
from plplot import *
 
3
 
 
4
# main
 
5
#
 
6
# Displays Greek letters and mathematically interesting Unicode ranges
 
7
 
 
8
Greek = (
 
9
"#gA","#gB","#gG","#gD","#gE","#gZ","#gY","#gH","#gI","#gK","#gL","#gM",
 
10
"#gN","#gC","#gO","#gP","#gR","#gS","#gT","#gU","#gF","#gX","#gQ","#gW",
 
11
"#ga","#gb","#gg","#gd","#ge","#gz","#gy","#gh","#gi","#gk","#gl","#gm",
 
12
"#gn","#gc","#go","#gp","#gr","#gs","#gt","#gu","#gf","#gx","#gq","#gw",
 
13
)
 
14
 
 
15
Type1 = (
 
16
"0x0020","0x0021","0x0023","0x0025","0x0026",
 
17
"0x0028","0x0029","0x002b","0x002c","0x002e",
 
18
"0x002f","0x0030","0x0031","0x0032","0x0033",
 
19
"0x0034","0x0035","0x0036","0x0037","0x0038",
 
20
"0x0039","0x003a","0x003b","0x003c","0x003d",
 
21
"0x003e","0x003f","0x005b","0x005d","0x005f",
 
22
"0x007b","0x007c","0x007d","0x00a9","0x00ac",
 
23
"0x00ae","0x00b0","0x00b1","0x00d7","0x00f7",
 
24
"0x0192","0x0391","0x0392","0x0393","0x0394",
 
25
"0x0395","0x0396","0x0397","0x0398","0x0399",
 
26
"0x039a","0x039b","0x039c","0x039d","0x039e",
 
27
"0x039f","0x03a0","0x03a1","0x03a3","0x03a4",
 
28
"0x03a5","0x03a6","0x03a7","0x03a8","0x03a9",
 
29
"0x03b1","0x03b2","0x03b3","0x03b4","0x03b5",
 
30
"0x03b6","0x03b7","0x03b8","0x03b9","0x03ba",
 
31
"0x03bb","0x03bc","0x03bd","0x03be","0x03bf",
 
32
"0x03c0","0x03c1","0x03c2","0x03c3","0x03c4",
 
33
"0x03c5","0x03c6","0x03c7","0x03c8","0x03c9",
 
34
"0x03d1","0x03d2","0x03d5","0x03d6","0x2022",
 
35
"0x2026","0x2032","0x2033","0x203e","0x2044",
 
36
"0x2111","0x2118","0x211c","0x2122","0x2126",
 
37
"0x2135","0x2190","0x2191","0x2192","0x2193",
 
38
"0x2194","0x21b5","0x21d0","0x21d1","0x21d2",
 
39
"0x21d3","0x21d4","0x2200","0x2202","0x2203",
 
40
"0x2205","0x2206","0x2207","0x2208","0x2209",
 
41
"0x220b","0x220f","0x2211","0x2212","0x2215",
 
42
"0x2217","0x221a","0x221d","0x221e","0x2220",
 
43
"0x2227","0x2228","0x2229","0x222a","0x222b",
 
44
"0x2234","0x223c","0x2245","0x2248","0x2260",
 
45
"0x2261","0x2264","0x2265","0x2282","0x2283",
 
46
"0x2284","0x2286","0x2287","0x2295","0x2297",
 
47
"0x22a5","0x22c5","0x2320","0x2321","0x2329",
 
48
"0x232a","0x25ca","0x2660","0x2663","0x2665",
 
49
"0x2666",
 
50
)
 
51
 
 
52
title = (
 
53
"#<0x10>PLplot Example 23 - Greek Letters",
 
54
"#<0x10>PLplot Example 23 - Type 1 Symbol Font Glyphs by Unicode (a)",
 
55
"#<0x10>PLplot Example 23 - Type 1 Symbol Font Glyphs by Unicode (b)",
 
56
"#<0x10>PLplot Example 23 - Type 1 Symbol Font Glyphs by Unicode (c)",
 
57
"#<0x10>PLplot Example 23 - Number Forms Unicode Block",
 
58
"#<0x10>PLplot Example 23 - Arrows Unicode Block (a)",
 
59
"#<0x10>PLplot Example 23 - Arrows Unicode Block (b)",
 
60
"#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (a)",
 
61
"#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (b)",
 
62
"#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (c)",
 
63
"#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (d)",
 
64
)
 
65
 
 
66
lo = (
 
67
"0x0",
 
68
"0x0",
 
69
"0x0",
 
70
"0x0",
 
71
"0x2153",
 
72
"0x2190",
 
73
"0x21d0",
 
74
"0x2200",
 
75
"0x2240",
 
76
"0x2280",
 
77
"0x22c0",
 
78
)
 
79
 
 
80
hi = (
 
81
"0x0",
 
82
"0x0",
 
83
"0x0",
 
84
"0x0",
 
85
"0x2184",
 
86
"0x21d0",
 
87
"0x2200",
 
88
"0x2240",
 
89
"0x2280",
 
90
"0x22c0",
 
91
"0x2300",
 
92
)
 
93
nxcells = (
 
94
12,
 
95
8,
 
96
8,
 
97
8,
 
98
8,
 
99
8,
 
100
8,
 
101
8,
 
102
8,
 
103
8,
 
104
8,
 
105
)
 
106
 
 
107
nycells = (
 
108
8,
 
109
8,
 
110
8,
 
111
8,
 
112
8,
 
113
8,
 
114
8,
 
115
8,
 
116
8,
 
117
8,
 
118
8,
 
119
)
 
120
 
 
121
# non-zero values Must be consistent with nxcells and nycells.
 
122
offset = (
 
123
0,
 
124
0,
 
125
64,
 
126
128,
 
127
0,
 
128
0,
 
129
0,
 
130
0,
 
131
0,
 
132
0,
 
133
0,
 
134
)
 
135
 
 
136
def main():
 
137
    
 
138
    for page in range(11):
 
139
        pladv(0)
 
140
 
 
141
        # Set up viewport and window
 
142
 
 
143
        plvpor(0.02, 0.98, 0.02, 0.90)
 
144
        plwind(0.0, 1.0, 0.0, 1.0)
 
145
        mm = plgspa()
 
146
        plschr(0., 0.8)
 
147
        ycharacter_scale = (1.0 - 0.0)/(mm[3]-mm[2])
 
148
        # Factor should be 0.5, but heuristically it turns out to be larger.
 
149
        yoffset = 1.0*plgchr()[1]*ycharacter_scale
 
150
 
 
151
        # Draw the grid using plbox
 
152
 
 
153
        plcol0(2)
 
154
        deltax = 1./float(nxcells[page])
 
155
        deltay = 1./float(nycells[page])
 
156
        plbox("bcg", deltax, 0, "bcg", deltay, 0)
 
157
        plcol0(15)
 
158
        if page == 0:
 
159
            # Greek letters.
 
160
            CommandString = Greek
 
161
        elif 1 <= page and page <= 3:
 
162
            # Unicode for Type 1 Symbol Glyphs.
 
163
            # Work around Numeric bug which only allows you to add one-character
 
164
            # strings to arrays of Pyobjects.
 
165
            CommandString = "#" + ("[" + array(Type1,PyObject)\
 
166
            [offset[page]:offset[page]+(nxcells[page]*nycells[page])] + "]")
 
167
        elif page >= 4:
 
168
            numarray = arange(int(lo[page],16),int(hi[page],16))
 
169
            symbolarray = []
 
170
            for number in numarray:
 
171
                symbolarray.append(hex(number))
 
172
            CommandString = "#" + ("[" + array(symbolarray,PyObject) + "]")
 
173
        length = len(CommandString)
 
174
        slice = 0
 
175
        for y in (0.5+arange(nycells[page]-1,-1,-1))*deltay:
 
176
            for x in (0.5+arange(nxcells[page]))*deltax:
 
177
                if slice < length:
 
178
                    plptex(x,y+yoffset,1.,0.,0.5, CommandString[slice])
 
179
                    plptex(x,y-yoffset,1.,0.,0.5, "#" +CommandString[slice])
 
180
                slice += 1
 
181
 
 
182
        plschr(0., 1.0)
 
183
        # Page title
 
184
        plmtex("t", 1.5, 0.5, 0.5, title[page])
 
185
 
 
186
    # Restore defaults
 
187
    plcol0(1)
 
188
 
 
189
main()