plplot 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +115 -0
- data/examples/x01.rb +284 -0
- data/examples/x02.rb +134 -0
- data/examples/x03.rb +81 -0
- data/examples/x04.rb +98 -0
- data/examples/x05.rb +33 -0
- data/examples/x06.rb +62 -0
- data/examples/x07.rb +69 -0
- data/examples/x08.rb +179 -0
- data/examples/x09.rb +371 -0
- data/examples/x10.rb +29 -0
- data/examples/x11.rb +151 -0
- data/examples/x12.rb +65 -0
- data/examples/x13.rb +86 -0
- data/examples/x14.rb +391 -0
- data/examples/x15.rb +266 -0
- data/examples/x16.rb +349 -0
- data/examples/x18.rb +146 -0
- data/examples/x20.rb +360 -0
- data/examples/x21.rb +280 -0
- data/examples/x22.rb +242 -0
- data/examples/x23.rb +361 -0
- data/examples/x24.rb +126 -0
- data/examples/x25.rb +114 -0
- data/examples/x26.rb +180 -0
- data/examples/x27.rb +124 -0
- data/examples/x28.rb +369 -0
- data/examples/x30.rb +141 -0
- data/examples/x31.rb +238 -0
- data/examples/x32.rb +159 -0
- data/ext/depend +1 -0
- data/ext/extconf.rb +75 -0
- data/ext/rbplplot.c +4982 -0
- data/lib/plplot.rb +101 -0
- metadata +115 -0
data/examples/x09.rb
ADDED
@@ -0,0 +1,371 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$-w = true if $0 == __FILE__
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'plplot'
|
6
|
+
include PLplot
|
7
|
+
include Math
|
8
|
+
|
9
|
+
# Contour plot demo.
|
10
|
+
#
|
11
|
+
# This file is part of PLplot.
|
12
|
+
#
|
13
|
+
# PLplot is free software; you can redistribute it and/or modify
|
14
|
+
# it under the terms of the GNU General Library Public License as published
|
15
|
+
# by the Free Software Foundation; either version 2 of the License, or
|
16
|
+
# (at your option) any later version.
|
17
|
+
#
|
18
|
+
# PLplot is distributed in the hope that it will be useful,
|
19
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21
|
+
# GNU Library General Public License for more details.
|
22
|
+
#
|
23
|
+
# You should have received a copy of the GNU Library General Public License
|
24
|
+
# along with PLplot; if not, write to the Free Software
|
25
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
26
|
+
|
27
|
+
|
28
|
+
XPTS = 35 # Data points in x
|
29
|
+
YPTS = 46 # Data points in y
|
30
|
+
|
31
|
+
XSPA = 2.0/(XPTS-1)
|
32
|
+
YSPA = 2.0/(YPTS-1)
|
33
|
+
|
34
|
+
# polar plot data
|
35
|
+
PERIMETERPTS = 100
|
36
|
+
RPTS = 40
|
37
|
+
THETAPTS = 40
|
38
|
+
|
39
|
+
# potential plot data
|
40
|
+
PPERIMETERPTS = 100
|
41
|
+
PRPTS = 40
|
42
|
+
PTHETAPTS = 64
|
43
|
+
PNLEVEL = 20
|
44
|
+
|
45
|
+
CLEVEL = [-1.0, -0.8, -0.6, -0.4, -0.2, 0.0, 0.2, 0.4, 0.6, 0.8, 1.0]
|
46
|
+
|
47
|
+
# Makes transliteration from C example easier
|
48
|
+
def pow(a,b)
|
49
|
+
a ** b
|
50
|
+
end
|
51
|
+
|
52
|
+
# Transformation function
|
53
|
+
|
54
|
+
TR = [XSPA, 0.0, -1.0, 0.0, YSPA, -1.0]
|
55
|
+
|
56
|
+
def mypltr(x, y, tr)
|
57
|
+
tx = tr[0] * x.to_f + tr[1] * y.to_f + tr[2];
|
58
|
+
ty = tr[3] * x.to_f + tr[4] * y.to_f + tr[5];
|
59
|
+
[tx, ty]
|
60
|
+
end
|
61
|
+
|
62
|
+
# polar contour plot example.
|
63
|
+
def polar
|
64
|
+
|
65
|
+
plenv(-1.0, 1.0, -1.0, 1.0, 0, -2);
|
66
|
+
plcol0(1);
|
67
|
+
|
68
|
+
# Perimeter
|
69
|
+
px = []
|
70
|
+
py = []
|
71
|
+
PERIMETERPTS.times do |i|
|
72
|
+
t = (2.0*PI/(PERIMETERPTS-1.0))*i;
|
73
|
+
px[i] = cos(t);
|
74
|
+
py[i] = sin(t);
|
75
|
+
end
|
76
|
+
plline(px, py);
|
77
|
+
|
78
|
+
# create data to be contoured.
|
79
|
+
xg = NArray.float(THETAPTS, RPTS);
|
80
|
+
yg = NArray.float(THETAPTS, RPTS);
|
81
|
+
z = NArray.float(THETAPTS, RPTS);
|
82
|
+
nx = RPTS;
|
83
|
+
ny = THETAPTS;
|
84
|
+
|
85
|
+
RPTS.times do |i|
|
86
|
+
r = i.to_f/(RPTS-1);
|
87
|
+
THETAPTS.times do |j|
|
88
|
+
theta = (2.0*PI/(THETAPTS-1.0))*j;
|
89
|
+
xg[j,i] = r*cos(theta);
|
90
|
+
yg[j,i] = r*sin(theta);
|
91
|
+
z[j,i] = r;
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
lev = [];
|
96
|
+
10.times do |i|
|
97
|
+
lev[i] = 0.05 + 0.10 * i;
|
98
|
+
end
|
99
|
+
|
100
|
+
plcol0(2);
|
101
|
+
plcont(z, nil, nil, lev, xg, yg)
|
102
|
+
plcol0(1);
|
103
|
+
pllab("", "", "Polar Contour Plot");
|
104
|
+
end
|
105
|
+
|
106
|
+
# shielded potential contour plot example.
|
107
|
+
def potential()
|
108
|
+
# create data to be contoured.
|
109
|
+
xg = NArray.float(PTHETAPTS, PRPTS);
|
110
|
+
yg = NArray.float(PTHETAPTS, PRPTS);
|
111
|
+
z = NArray.float(PTHETAPTS, PRPTS);
|
112
|
+
nx = PRPTS;
|
113
|
+
ny = PTHETAPTS;
|
114
|
+
|
115
|
+
PRPTS.times do |i|
|
116
|
+
r = 0.5 + i;
|
117
|
+
PTHETAPTS.times do |j|
|
118
|
+
theta = (2.0*PI/(PTHETAPTS-1.0))*(0.5 + j);
|
119
|
+
xg[j,i] = r*cos(theta);
|
120
|
+
yg[j,i] = r*sin(theta);
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
rmax = PRPTS;
|
125
|
+
xmin, xmax = plMinMax2dGrid(xg);
|
126
|
+
ymin, ymax = plMinMax2dGrid(yg);
|
127
|
+
x0 = (xmin + xmax)/2.0;
|
128
|
+
y0 = (ymin + ymax)/2.0;
|
129
|
+
|
130
|
+
# Expanded limits
|
131
|
+
peps = 0.05;
|
132
|
+
xpmin = xmin - xmin.abs*peps;
|
133
|
+
xpmax = xmax + xmax.abs*peps;
|
134
|
+
ypmin = ymin - ymin.abs*peps;
|
135
|
+
ypmax = ymax + ymax.abs*peps;
|
136
|
+
|
137
|
+
# Potential inside a conducting cylinder (or sphere) by method of images.
|
138
|
+
# Charge 1 is placed at (d1, d1), with image charge at (d2, d2).
|
139
|
+
# Charge 2 is placed at (d1, -d1), with image charge at (d2, -d2).
|
140
|
+
# Also put in smoothing term at small distances.
|
141
|
+
|
142
|
+
eps = 2.0;
|
143
|
+
|
144
|
+
q1 = 1.0;
|
145
|
+
d1 = rmax/4.0;
|
146
|
+
|
147
|
+
q1i = - q1*rmax/d1;
|
148
|
+
d1i = pow(rmax, 2.0)/d1;
|
149
|
+
|
150
|
+
q2 = -1.0;
|
151
|
+
d2 = rmax/4.0;
|
152
|
+
|
153
|
+
q2i = - q2*rmax/d2;
|
154
|
+
d2i = pow(rmax, 2.0)/d2;
|
155
|
+
|
156
|
+
PRPTS.times do |i|
|
157
|
+
PTHETAPTS.times do |j|
|
158
|
+
div1 = sqrt(pow(xg[j,i]-d1, 2.0) + pow(yg[j,i]-d1, 2.0) + pow(eps, 2.0));
|
159
|
+
div1i = sqrt(pow(xg[j,i]-d1i, 2.0) + pow(yg[j,i]-d1i, 2.0) + pow(eps, 2.0));
|
160
|
+
div2 = sqrt(pow(xg[j,i]-d2, 2.0) + pow(yg[j,i]+d2, 2.0) + pow(eps, 2.0));
|
161
|
+
div2i = sqrt(pow(xg[j,i]-d2i, 2.0) + pow(yg[j,i]+d2i, 2.0) + pow(eps, 2.0));
|
162
|
+
z[j,i] = q1/div1 + q1i/div1i + q2/div2 + q2i/div2i;
|
163
|
+
end
|
164
|
+
end
|
165
|
+
zmin, zmax = plMinMax2dGrid(z);
|
166
|
+
=begin
|
167
|
+
printf("%.15g %.15g %.15g %.15g %.15g %.15g %.15g %.15g \n",
|
168
|
+
q1, d1, q1i, d1i, q2, d2, q2i, d2i);
|
169
|
+
printf("%.15g %.15g %.15g %.15g %.15g %.15g \n",
|
170
|
+
xmin, xmax, ymin, ymax, zmin, zmax);
|
171
|
+
=end
|
172
|
+
|
173
|
+
# Positive and negative contour levels.
|
174
|
+
dz = (zmax-zmin)/PNLEVEL;
|
175
|
+
nlevelneg = 0;
|
176
|
+
nlevelpos = 0;
|
177
|
+
clevelneg = []
|
178
|
+
clevelpos = []
|
179
|
+
PNLEVEL.times do |i|
|
180
|
+
clevel = zmin + (i + 0.5)*dz;
|
181
|
+
if (clevel <= 0.0)
|
182
|
+
clevelneg[nlevelneg] = clevel;
|
183
|
+
nlevelneg += 1
|
184
|
+
else
|
185
|
+
clevelpos[nlevelpos] = clevel;
|
186
|
+
nlevelpos += 1
|
187
|
+
end
|
188
|
+
end
|
189
|
+
# Colours!
|
190
|
+
ncollin = 11;
|
191
|
+
ncolbox = 1;
|
192
|
+
ncollab = 2;
|
193
|
+
|
194
|
+
# Finally start plotting this page!
|
195
|
+
pladv(0);
|
196
|
+
plcol0(ncolbox);
|
197
|
+
|
198
|
+
plvpas(0.1, 0.9, 0.1, 0.9, 1.0);
|
199
|
+
plwind(xpmin, xpmax, ypmin, ypmax);
|
200
|
+
plbox("", 0.0, 0, "", 0.0, 0);
|
201
|
+
|
202
|
+
plcol0(ncollin);
|
203
|
+
if(nlevelneg > 0)
|
204
|
+
# Negative contours
|
205
|
+
pllsty(2);
|
206
|
+
plcont(z, nil, nil, clevelneg, xg, yg);
|
207
|
+
end
|
208
|
+
|
209
|
+
if(nlevelpos >0)
|
210
|
+
# Positive contours
|
211
|
+
pllsty(1);
|
212
|
+
plcont(z, nil, nil, clevelpos, xg, yg);
|
213
|
+
end
|
214
|
+
|
215
|
+
# Draw outer boundary
|
216
|
+
px = NArray.float(PPERIMETERPTS)
|
217
|
+
py = NArray.float(PPERIMETERPTS)
|
218
|
+
PPERIMETERPTS.times do |i|
|
219
|
+
t = (2.0*PI/(PPERIMETERPTS-1.0))*i;
|
220
|
+
px[i] = x0 + rmax*cos(t);
|
221
|
+
py[i] = y0 + rmax*sin(t);
|
222
|
+
end
|
223
|
+
|
224
|
+
plcol0(ncolbox);
|
225
|
+
plline(px, py);
|
226
|
+
|
227
|
+
plcol0(ncollab);
|
228
|
+
pllab("", "", "Shielded potential of charges in a conducting sphere");
|
229
|
+
end
|
230
|
+
|
231
|
+
|
232
|
+
#--------------------------------------------------------------------------
|
233
|
+
# Does several contour plots using different coordinate mappings.
|
234
|
+
#--------------------------------------------------------------------------
|
235
|
+
|
236
|
+
mark = 1500
|
237
|
+
space = 1500
|
238
|
+
|
239
|
+
# Parse and process command line arguments
|
240
|
+
|
241
|
+
PLOptionParser.parse!
|
242
|
+
|
243
|
+
# Initialize plplot
|
244
|
+
|
245
|
+
plinit();
|
246
|
+
|
247
|
+
# Set up function arrays
|
248
|
+
|
249
|
+
xg1 = NArray.float(XPTS)
|
250
|
+
yg1 = NArray.float(YPTS);
|
251
|
+
z = NArray.float(YPTS, XPTS);
|
252
|
+
w = NArray.float(YPTS, XPTS);
|
253
|
+
|
254
|
+
XPTS.times do |i|
|
255
|
+
xx = (i - (XPTS / 2.0)) / (XPTS / 2.0);
|
256
|
+
YPTS.times do |j|
|
257
|
+
yy = (j - (YPTS / 2.0)) / (YPTS / 2.0) - 1.0;
|
258
|
+
z[j,i] = xx * xx - yy * yy;
|
259
|
+
w[j,i] = 2 * xx * yy;
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
# Set up grids
|
264
|
+
|
265
|
+
xg = NArray.float(YPTS, XPTS)
|
266
|
+
yg = NArray.float(YPTS, XPTS);
|
267
|
+
|
268
|
+
XPTS.times do |i|
|
269
|
+
YPTS.times do |j|
|
270
|
+
xx, yy = mypltr(i, j, TR);
|
271
|
+
|
272
|
+
argx = xx * PI/2;
|
273
|
+
argy = yy * PI/2;
|
274
|
+
distort = 0.4;
|
275
|
+
|
276
|
+
xg1[i] = xx + distort * cos(argx);
|
277
|
+
yg1[j] = yy - distort * cos(argy);
|
278
|
+
|
279
|
+
xg[j,i] = xx + distort * cos(argx) * cos(argy);
|
280
|
+
yg[j,i] = yy - distort * cos(argx) * cos(argy);
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
# Plot using identity transform
|
285
|
+
=begin
|
286
|
+
plenv(-1.0, 1.0, -1.0, 1.0, 0, 0);
|
287
|
+
plcol0(2);
|
288
|
+
plcont(z, nil, nil, CLEVEL) {|x,y| mypltr(x,y,TR)}
|
289
|
+
plstyl(mark, space);
|
290
|
+
plcol0(3);
|
291
|
+
plcont(w, nil, nil, CLEVEL) {|x,y| mypltr(x,y,TR)}
|
292
|
+
plstyl
|
293
|
+
plcol0(1);
|
294
|
+
pllab("X Coordinate", "Y Coordinate", "Streamlines of flow");
|
295
|
+
=end
|
296
|
+
pl_setcontlabelformat(4,3);
|
297
|
+
pl_setcontlabelparam(0.006, 0.3, 0.1, 1);
|
298
|
+
plenv(-1.0, 1.0, -1.0, 1.0, 0, 0);
|
299
|
+
plcol0(2);
|
300
|
+
plcont(z, nil, nil, CLEVEL) {|x,y| mypltr(x,y,TR)}
|
301
|
+
plstyl(mark, space);
|
302
|
+
plcol0(3);
|
303
|
+
plcont(w, nil, nil, CLEVEL) {|x,y| mypltr(x,y,TR)}
|
304
|
+
plstyl
|
305
|
+
plcol0(1);
|
306
|
+
pllab("X Coordinate", "Y Coordinate", "Streamlines of flow");
|
307
|
+
pl_setcontlabelparam(0.006, 0.3, 0.1, 0);
|
308
|
+
|
309
|
+
# Plot using 1d coordinate transform
|
310
|
+
|
311
|
+
plenv(-1.0, 1.0, -1.0, 1.0, 0, 0);
|
312
|
+
plcol0(2);
|
313
|
+
plcont(z, nil, nil, CLEVEL, xg1, yg1)
|
314
|
+
|
315
|
+
plstyl(mark, space);
|
316
|
+
plcol0(3);
|
317
|
+
plcont(w, nil, nil, CLEVEL, xg1, yg1)
|
318
|
+
plstyl
|
319
|
+
plcol0(1);
|
320
|
+
pllab("X Coordinate", "Y Coordinate", "Streamlines of flow");
|
321
|
+
=begin
|
322
|
+
pl_setcontlabelparam(0.006, 0.3, 0.1, 1);
|
323
|
+
plenv(-1.0, 1.0, -1.0, 1.0, 0, 0);
|
324
|
+
plcol0(2);
|
325
|
+
plcont(z, nil, nil, CLEVEL, xg1, yg1)
|
326
|
+
|
327
|
+
plstyl(mark, space);
|
328
|
+
plcol0(3);
|
329
|
+
plcont(z, nil, nil, CLEVEL, xg1, yg1)
|
330
|
+
plstyl
|
331
|
+
plcol0(1);
|
332
|
+
pllab("X Coordinate", "Y Coordinate", "Streamlines of flow");
|
333
|
+
pl_setcontlabelparam(0.006, 0.3, 0.1, 0);
|
334
|
+
=end
|
335
|
+
|
336
|
+
# Plot using 2d coordinate transform
|
337
|
+
|
338
|
+
plenv(-1.0, 1.0, -1.0, 1.0, 0, 0);
|
339
|
+
plcol0(2);
|
340
|
+
plcont(z, nil, nil, CLEVEL, xg, yg)
|
341
|
+
|
342
|
+
plstyl(mark, space);
|
343
|
+
plcol0(3);
|
344
|
+
plcont(w, nil, nil, CLEVEL, xg, yg)
|
345
|
+
plstyl
|
346
|
+
plcol0(1);
|
347
|
+
pllab("X Coordinate", "Y Coordinate", "Streamlines of flow");
|
348
|
+
=begin
|
349
|
+
pl_setcontlabelparam(0.006, 0.3, 0.1, 1);
|
350
|
+
plenv(-1.0, 1.0, -1.0, 1.0, 0, 0);
|
351
|
+
plcol0(2);
|
352
|
+
plcont(z, nil, nil, CLEVEL, xg, yg)
|
353
|
+
|
354
|
+
plstyl(mark, space);
|
355
|
+
plcol0(3);
|
356
|
+
plcont(w, nil, nil, CLEVEL, xg, yg)
|
357
|
+
plstyl(
|
358
|
+
plcol0(1);
|
359
|
+
pllab("X Coordinate", "Y Coordinate", "Streamlines of flow");
|
360
|
+
=end
|
361
|
+
pl_setcontlabelparam(0.006, 0.3, 0.1, 0);
|
362
|
+
#pl_setcontlabelparam(0.006, 0.3, 0.1, 1);
|
363
|
+
polar();
|
364
|
+
|
365
|
+
pl_setcontlabelparam(0.006, 0.3, 0.1, 0);
|
366
|
+
#pl_setcontlabelparam(0.006, 0.3, 0.1, 1);
|
367
|
+
potential();
|
368
|
+
|
369
|
+
# Clean up
|
370
|
+
|
371
|
+
plend();
|
data/examples/x10.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$-w = true if $0 == __FILE__
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'plplot'
|
6
|
+
include PLplot
|
7
|
+
|
8
|
+
# Window positioning demo.
|
9
|
+
#
|
10
|
+
# Demonstrates absolute positioning of graphs on a page.
|
11
|
+
|
12
|
+
# Parse and process command line arguments
|
13
|
+
|
14
|
+
PLOptionParser.parse!
|
15
|
+
|
16
|
+
# Initialize plplot
|
17
|
+
|
18
|
+
plinit
|
19
|
+
|
20
|
+
pladv(0)
|
21
|
+
plvpor(0.0, 1.0, 0.0, 1.0)
|
22
|
+
plwind(0.0, 1.0, 0.0, 1.0)
|
23
|
+
plbox("bc", 0.0, 0, "bc", 0.0, 0)
|
24
|
+
|
25
|
+
plsvpa(50.0, 150.0, 50.0, 100.0)
|
26
|
+
plwind(0.0, 1.0, 0.0, 1.0)
|
27
|
+
plbox("bc", 0.0, 0, "bc", 0.0, 0)
|
28
|
+
plptex(0.5, 0.5, 1.0, 0.0, 0.5, "BOX at (50,150,50,100)")
|
29
|
+
plend
|
data/examples/x11.rb
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$-w = true if $0 == __FILE__
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'plplot'
|
6
|
+
include PLplot
|
7
|
+
include Math
|
8
|
+
|
9
|
+
# Mesh plot demo.
|
10
|
+
#
|
11
|
+
# Copyright (C) 2004 Rafael Laboissiere
|
12
|
+
#
|
13
|
+
# This file is part of PLplot.
|
14
|
+
#
|
15
|
+
# PLplot is free software; you can redistribute it and/or modify
|
16
|
+
# it under the terms of the GNU General Library Public License as published
|
17
|
+
# by the Free Software Foundation; either version 2 of the License, or
|
18
|
+
# (at your option) any later version.
|
19
|
+
#
|
20
|
+
# PLplot is distributed in the hope that it will be useful,
|
21
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
22
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
23
|
+
# GNU Library General Public License for more details.
|
24
|
+
#
|
25
|
+
# You should have received a copy of the GNU Library General Public License
|
26
|
+
# along with PLplot; if not, write to the Free Software
|
27
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
28
|
+
|
29
|
+
XPTS = 35 # Data points in x
|
30
|
+
YPTS = 46 # Data points in y
|
31
|
+
LEVELS = 10
|
32
|
+
|
33
|
+
opt = [ PL::DRAW_LINEXY, PL::DRAW_LINEXY ]
|
34
|
+
|
35
|
+
alt = [ 33.0, 17.0 ]
|
36
|
+
az = [ 24.0, 115.0 ]
|
37
|
+
|
38
|
+
title = [
|
39
|
+
"#frPLplot Example 11 - Alt=33, Az=24, Opt=3",
|
40
|
+
"#frPLplot Example 11 - Alt=17, Az=115, Opt=3",
|
41
|
+
]
|
42
|
+
|
43
|
+
# Makes transliteration from C example easier
|
44
|
+
def pow(a,b)
|
45
|
+
a ** b
|
46
|
+
end
|
47
|
+
|
48
|
+
def cmap1_init()
|
49
|
+
|
50
|
+
i = [0.0, 1.0] # left, right boundaries
|
51
|
+
|
52
|
+
h = [240, 0] # blue -> green -> yellow -> red
|
53
|
+
l = [0.6, 0.6]
|
54
|
+
s = [0.8, 0.8]
|
55
|
+
|
56
|
+
plscmap1n( 256 )
|
57
|
+
plscmap1l(PL::CMAP_HLS, i, h, l, s)
|
58
|
+
end
|
59
|
+
|
60
|
+
#--------------------------------------------------------------------------
|
61
|
+
# Does a series of mesh plots for a given data set, with different
|
62
|
+
# viewing options in each plot.
|
63
|
+
#--------------------------------------------------------------------------
|
64
|
+
|
65
|
+
# Parse and process command line arguments
|
66
|
+
|
67
|
+
PLOptionParser.parse!
|
68
|
+
|
69
|
+
# Initialize plplot
|
70
|
+
|
71
|
+
plinit
|
72
|
+
|
73
|
+
# Could be done more tersely using NArray methods, but this is a closer
|
74
|
+
# transliteration from the C example.
|
75
|
+
|
76
|
+
x = NArray.float(XPTS)
|
77
|
+
y = NArray.float(YPTS)
|
78
|
+
|
79
|
+
z = NArray.float(YPTS, XPTS)
|
80
|
+
|
81
|
+
XPTS.times do |i|
|
82
|
+
x[i] = 3.0 * ( i - ( XPTS / 2.0 ) ) / ( XPTS / 2.0 )
|
83
|
+
end
|
84
|
+
|
85
|
+
YPTS.times do |i|
|
86
|
+
y[i] = 3.0 * ( i - ( YPTS / 2.0 ) ) / ( YPTS / 2.0 )
|
87
|
+
end
|
88
|
+
|
89
|
+
XPTS.times do |i|
|
90
|
+
xx = x[i]
|
91
|
+
YPTS.times do |j|
|
92
|
+
yy = y[j]
|
93
|
+
z[j,i] = 3.0 * ( 1.0 - xx ) * ( 1.0 - xx ) * exp( -( xx * xx ) - ( yy + 1.0 ) * ( yy + 1.0 ) ) -
|
94
|
+
10.0 * ( xx / 5.0 - pow( xx, 3.0 ) - pow( yy, 5.0 ) ) * exp( -xx * xx - yy * yy ) -
|
95
|
+
1.0 / 3.0 * exp( -( xx + 1 ) * ( xx + 1 ) - ( yy * yy ) )
|
96
|
+
|
97
|
+
if ( false ) # Jungfraujoch/Interlaken
|
98
|
+
if ( z[j,i] < -1.0 )
|
99
|
+
z[j,i] = -1.0
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
zmin, zmax = plMinMax2dGrid(z)
|
106
|
+
step = (zmax - zmin) / (LEVELS + 1)
|
107
|
+
clevel = []
|
108
|
+
LEVELS.times do |i|
|
109
|
+
clevel[i] = zmin + step + step * i
|
110
|
+
end
|
111
|
+
|
112
|
+
cmap1_init()
|
113
|
+
2.times do |k|
|
114
|
+
4.times do |i|
|
115
|
+
pladv( 0 )
|
116
|
+
plcol0( 1 )
|
117
|
+
plvpor( 0.0, 1.0, 0.0, 0.9 )
|
118
|
+
plwind( -1.0, 1.0, -1.0, 1.5 )
|
119
|
+
plw3d( 1.0, 1.0, 1.2, -3.0, 3.0, -3.0, 3.0, zmin, zmax, alt[k], az[k] )
|
120
|
+
plbox3( "bnstu", "x axis", 0.0, 0,
|
121
|
+
"bnstu", "y axis", 0.0, 0,
|
122
|
+
"bcdmnstuv", "z axis", 0.0, 4 )
|
123
|
+
|
124
|
+
plcol0( 2 )
|
125
|
+
|
126
|
+
# wireframe plot
|
127
|
+
if ( i == 0 )
|
128
|
+
plmesh( x, y, z, opt[k] )
|
129
|
+
|
130
|
+
# magnitude colored wireframe plot
|
131
|
+
elsif ( i == 1 )
|
132
|
+
plmesh( x, y, z, opt[k] | PL::MAG_COLOR )
|
133
|
+
|
134
|
+
# magnitude colored wireframe plot with sides
|
135
|
+
elsif ( i == 2 )
|
136
|
+
plot3d( x, y, z, opt[k] | PL::MAG_COLOR, 1 )
|
137
|
+
|
138
|
+
# magnitude colored wireframe plot with base contour
|
139
|
+
elsif ( i == 3 )
|
140
|
+
#plmeshc( x, y, z, opt[k] | PL::MAG_COLOR | PL::BASE_CONT, clevel )
|
141
|
+
#plmeshc( x, y, z, opt[k] | PL::MAG_COLOR | PL::SURF_CONT, clevel )
|
142
|
+
plmeshc( x, y, z, opt[k] | PL::MAG_COLOR | PL::TOP_CONT, clevel )
|
143
|
+
end
|
144
|
+
|
145
|
+
plcol0( 3 )
|
146
|
+
plmtex( "t", 1.0, 0.5, 0.5, title[k] )
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
# Clean up
|
151
|
+
plend
|