plplot 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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/x30.rb
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$-w = true if $0 == __FILE__
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'plplot'
|
6
|
+
include PLplot
|
7
|
+
|
8
|
+
# Alpha color values demonstration.
|
9
|
+
#
|
10
|
+
# Copyright (C) 2008 Hazen Babcock
|
11
|
+
#
|
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
|
+
# This example will only really be interesting when used with devices that
|
30
|
+
# support or alpha (or transparency) values, such as the cairo device family.
|
31
|
+
|
32
|
+
red = [ 0, 255, 0, 0 ]
|
33
|
+
green = [ 0, 0, 255, 0 ]
|
34
|
+
blue = [ 0, 0, 0, 255 ]
|
35
|
+
alpha = [ 1.0, 1.0, 1.0, 1.0 ]
|
36
|
+
|
37
|
+
px = [ 0.1, 0.5, 0.5, 0.1 ]
|
38
|
+
py = [ 0.1, 0.1, 0.5, 0.5 ]
|
39
|
+
|
40
|
+
pos = [ 0.0, 1.0 ]
|
41
|
+
rcoord = [ 1.0, 1.0 ]
|
42
|
+
gcoord = [ 0.0, 0.0 ]
|
43
|
+
bcoord = [ 0.0, 0.0 ]
|
44
|
+
acoord = [ 0.0, 1.0 ]
|
45
|
+
rev = [ 0, 0 ]
|
46
|
+
|
47
|
+
PLOptionParser.parse!
|
48
|
+
|
49
|
+
plinit
|
50
|
+
plscmap0n(4)
|
51
|
+
plscmap0a(red, green, blue, alpha)
|
52
|
+
|
53
|
+
# Page 1:
|
54
|
+
#
|
55
|
+
# This is a series of red, green and blue rectangles overlaid
|
56
|
+
# on each other with gradually increasing transparency.
|
57
|
+
|
58
|
+
# Set up the window
|
59
|
+
pladv(0)
|
60
|
+
plvpor(0.0, 1.0, 0.0, 1.0)
|
61
|
+
plwind(0.0, 1.0, 0.0, 1.0)
|
62
|
+
plcol0(0)
|
63
|
+
plbox("", 1.0, 0, "", 1.0, 0)
|
64
|
+
|
65
|
+
# Draw the boxes
|
66
|
+
9.times do |i|
|
67
|
+
icol = i % 3 + 1
|
68
|
+
|
69
|
+
# Get a color, change its transparency and
|
70
|
+
# set it as the current color.
|
71
|
+
r, g, b, a = plgcol0a(icol)
|
72
|
+
plscol0a(icol, r, g, b, 1 - i / 9.0)
|
73
|
+
plcol0(icol)
|
74
|
+
|
75
|
+
# Draw the rectangle
|
76
|
+
plfill(px, py)
|
77
|
+
|
78
|
+
# Shift the rectangles coordinates
|
79
|
+
4.times do |j|
|
80
|
+
px[j] += 0.5 / 9.0
|
81
|
+
py[j] += 0.5 / 9.0
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Page 2:
|
86
|
+
#
|
87
|
+
# This is a bunch of boxes colored red, green or blue with a single
|
88
|
+
# large (red) box of linearly varying transparency overlaid. The
|
89
|
+
# overlaid box is completely transparent at the bottom and completely
|
90
|
+
# opaque at the top.
|
91
|
+
|
92
|
+
# Set up the window
|
93
|
+
pladv(0)
|
94
|
+
plvpor(0.1, 0.9, 0.1, 0.9)
|
95
|
+
plwind(0.0, 1.0, 0.0, 1.0)
|
96
|
+
|
97
|
+
# Draw the boxes. There are 25 of them drawn on a 5 x 5 grid.
|
98
|
+
5.times do |i|
|
99
|
+
# Set box X position
|
100
|
+
px[0] = 0.05 + 0.2 * i
|
101
|
+
px[1] = px[0] + 0.1
|
102
|
+
px[2] = px[1]
|
103
|
+
px[3] = px[0]
|
104
|
+
|
105
|
+
# We don't want the boxes to be transparent, so since we changed
|
106
|
+
# the colors transparencies in the first example we have to change
|
107
|
+
# the transparencies back to completely opaque.
|
108
|
+
icol = i % 3 + 1
|
109
|
+
r, g, b, a = plgcol0a(icol)
|
110
|
+
plscol0a(icol, r, g, b, 1)
|
111
|
+
plcol0(icol)
|
112
|
+
5.times do |j|
|
113
|
+
# Set box y position and draw the box.
|
114
|
+
py[0] = 0.05 + 0.2 * j
|
115
|
+
py[1] = py[0]
|
116
|
+
py[2] = py[0] + 0.1
|
117
|
+
py[3] = py[2]
|
118
|
+
plfill(px, py)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
# Create the color map with 128 colors and use plscmap1la to initialize
|
123
|
+
# the color values with a linearly varying red transparency (or alpha)
|
124
|
+
plscmap1n(128)
|
125
|
+
plscmap1la(1, pos, rcoord, gcoord, bcoord, acoord, rev)
|
126
|
+
|
127
|
+
# Use that cmap1 to create a transparent red gradient for the whole
|
128
|
+
# window.
|
129
|
+
px[0] = 0
|
130
|
+
px[1] = 1
|
131
|
+
px[2] = 1
|
132
|
+
px[3] = 0
|
133
|
+
|
134
|
+
py[0] = 0
|
135
|
+
py[1] = 0
|
136
|
+
py[2] = 1
|
137
|
+
py[3] = 1
|
138
|
+
|
139
|
+
plgradient(px, py, 90)
|
140
|
+
|
141
|
+
plend
|
data/examples/x31.rb
ADDED
@@ -0,0 +1,238 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$-w = true if $0 == __FILE__
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'plplot'
|
6
|
+
include PLplot
|
7
|
+
|
8
|
+
# Copyright (C) 2008 Alan W. Irwin
|
9
|
+
# Copyright (C) 2008 Andrew Ross
|
10
|
+
#
|
11
|
+
# set/get tester
|
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
|
+
# Allow conversion of booleans to ints
|
30
|
+
class FalseClass; def to_i; 0; end; end
|
31
|
+
class TrueClass; def to_i; 1; end; end
|
32
|
+
|
33
|
+
r1 = [ 0, 255 ]
|
34
|
+
g1 = [ 255, 0 ]
|
35
|
+
b1 = [ 0, 0 ]
|
36
|
+
a1 = [ 1, 1 ]
|
37
|
+
|
38
|
+
status = 0
|
39
|
+
|
40
|
+
# Parse and process command line arguments
|
41
|
+
|
42
|
+
PLOptionParser.parse!
|
43
|
+
|
44
|
+
# Test setting / getting familying parameters before plinit
|
45
|
+
# Save values set by plparseopts to be restored later.
|
46
|
+
# This shows how to use "parallel assignment" to assign
|
47
|
+
# each return value to a separate variable.
|
48
|
+
fam0, num0, bmax0 = plgfam
|
49
|
+
fam1 = false
|
50
|
+
num1 = 10
|
51
|
+
bmax1 = 1000
|
52
|
+
plsfam(fam1, num1, bmax1)
|
53
|
+
|
54
|
+
# Retrieve the same values?
|
55
|
+
fam2, num2, bmax2 = plgfam
|
56
|
+
printf("family parameters: fam, num, bmax = %d %d %d\n", fam2, num2, bmax2)
|
57
|
+
if fam2 != fam1 || num2 != num1 || bmax2 != bmax1
|
58
|
+
STDERR.puts("plgfam test failed\n")
|
59
|
+
status = 1
|
60
|
+
end
|
61
|
+
# Restore values set initially by plparseopts
|
62
|
+
plsfam(fam0, num0, bmax0)
|
63
|
+
|
64
|
+
# Test setting / getting page parameters before plinit
|
65
|
+
# Save values set by plparseopts to be restored later.
|
66
|
+
# This shows how to save all return values in an Array
|
67
|
+
# for use with the "splat" operator when restoring.
|
68
|
+
page0 = plgpage
|
69
|
+
xp1 = 200
|
70
|
+
yp1 = 200
|
71
|
+
xleng1 = 400
|
72
|
+
yleng1 = 200
|
73
|
+
xoff1 = 10
|
74
|
+
yoff1 = 20
|
75
|
+
plspage(xp1, yp1, xleng1, yleng1, xoff1, yoff1)
|
76
|
+
|
77
|
+
# Retrieve the same values?
|
78
|
+
xp2, yp2, xleng2, yleng2, xoff2, yoff2 = plgpage
|
79
|
+
printf("page parameters: xp, yp, xleng, yleng, xoff, yoff = %f %f %d %d %d %d\n", xp2, yp2, xleng2, yleng2, xoff2, yoff2)
|
80
|
+
if (xp2 != xp1 || yp2 != yp1 || xleng2 != xleng1 || yleng2 != yleng1 ||
|
81
|
+
xoff2 != xoff1 || yoff2 != yoff1)
|
82
|
+
STDERR.puts("plgpage test failed\n")
|
83
|
+
status = 1
|
84
|
+
end
|
85
|
+
# Restore values set initially by plparseopts.
|
86
|
+
plspage(*page0)
|
87
|
+
|
88
|
+
# Test setting / getting compression parameter across plinit.
|
89
|
+
compression1 = 95
|
90
|
+
plscompression(compression1)
|
91
|
+
|
92
|
+
# Initialize plplot
|
93
|
+
plinit
|
94
|
+
|
95
|
+
# Test if device initialization screwed around with the preset
|
96
|
+
# compression parameter.
|
97
|
+
compression2 = plgcompression
|
98
|
+
printf("Output various PLplot parameters\n")
|
99
|
+
printf("compression parameter = %d\n", compression2)
|
100
|
+
if (compression2 != compression1)
|
101
|
+
STDERR.puts("plgcompression test failed\n")
|
102
|
+
status = 1
|
103
|
+
end
|
104
|
+
|
105
|
+
# Exercise plscolor, plscol0, plscmap1, and plscmap1a to make sure
|
106
|
+
# they work without any obvious error messages.
|
107
|
+
plscolor(1)
|
108
|
+
plscol0(1, 255, 0, 0)
|
109
|
+
plscmap1(r1, g1, b1)
|
110
|
+
plscmap1a(r1, g1, b1, a1)
|
111
|
+
|
112
|
+
level2 = plglevel
|
113
|
+
printf("level parameter = %d\n", level2)
|
114
|
+
if (level2 != 1)
|
115
|
+
STDERR.puts("plglevel test failed.\n")
|
116
|
+
status = 1
|
117
|
+
end
|
118
|
+
|
119
|
+
pladv(0)
|
120
|
+
plvpor(0.01, 0.99, 0.02, 0.49)
|
121
|
+
xmin, xmax, ymin, ymax = plgvpd
|
122
|
+
printf("plvpor: xmin, xmax, ymin, ymax = %f %f %f %f\n", xmin, xmax, ymin, ymax)
|
123
|
+
if (xmin != 0.01 || xmax != 0.99 || ymin != 0.02 || ymax != 0.49)
|
124
|
+
STDERR.puts("plgvpd test failed\n")
|
125
|
+
status = 1
|
126
|
+
end
|
127
|
+
xmid = 0.5 * (xmin + xmax)
|
128
|
+
ymid = 0.5 * (ymin + ymax)
|
129
|
+
|
130
|
+
plwind(0.2, 0.3, 0.4, 0.5)
|
131
|
+
xmin, xmax, ymin, ymax = plgvpw
|
132
|
+
printf("plwind: xmin, xmax, ymin, ymax = %f %f %f %f\n", xmin, xmax, ymin, ymax)
|
133
|
+
if (xmin != 0.2 || xmax != 0.3 || ymin != 0.4 || ymax != 0.5)
|
134
|
+
STDERR.puts("plgvpw test failed\n")
|
135
|
+
status = 1
|
136
|
+
end
|
137
|
+
|
138
|
+
# Get world coordinates for middle of viewport
|
139
|
+
wx, wy, win = plcalc_world(xmid, ymid)
|
140
|
+
printf("world parameters: wx, wy, win = %f %f %d\n", wx, wy, win)
|
141
|
+
if (wx - 0.5 * (xmin + xmax)).abs > 1.0E-5 || (wy - 0.5 * (ymin + ymax)).abs > 1.0E-5
|
142
|
+
STDERR.puts("plcalc_world test failed\n")
|
143
|
+
status = 1
|
144
|
+
end
|
145
|
+
|
146
|
+
# Retrieve and print the name of the output file (if any).
|
147
|
+
# This goes to stderr not stdout since it will vary between tests and
|
148
|
+
# we want stdout to be identical for compare test.
|
149
|
+
fnam = plgfnam
|
150
|
+
if fnam.empty?
|
151
|
+
printf("No output file name is set\n")
|
152
|
+
else
|
153
|
+
printf("Output file name read\n")
|
154
|
+
end
|
155
|
+
STDERR.printf("Output file name is %s\n", fnam)
|
156
|
+
|
157
|
+
# Set and get the number of digits used to display axis labels
|
158
|
+
# Note digits is currently ignored in pls[xyz]ax and
|
159
|
+
# therefore it does not make sense to test the returned
|
160
|
+
# value
|
161
|
+
plsxax(3, 0)
|
162
|
+
digmax, digits = plgxax
|
163
|
+
printf("x axis parameters: digmax, digits = %d %d\n", digmax, digits)
|
164
|
+
if digmax != 3
|
165
|
+
STDERR.puts("plgxax test failed\n")
|
166
|
+
status = 1
|
167
|
+
end
|
168
|
+
|
169
|
+
plsyax(4, 0)
|
170
|
+
digmax, digits = plgyax
|
171
|
+
printf("y axis parameters: digmax, digits = %d %d\n", digmax, digits)
|
172
|
+
if (digmax != 4)
|
173
|
+
STDERR.puts("plgyax test failed\n")
|
174
|
+
status = 1
|
175
|
+
end
|
176
|
+
|
177
|
+
plszax(5, 0)
|
178
|
+
digmax, digits = plgzax
|
179
|
+
printf("z axis parameters: digmax, digits = %d %d\n", digmax, digits)
|
180
|
+
if (digmax != 5)
|
181
|
+
STDERR.puts("plgzax test failed\n")
|
182
|
+
status = 1
|
183
|
+
end
|
184
|
+
|
185
|
+
plsdidev(0.05, PL::NOTSET, 0.1, 0.2)
|
186
|
+
mar, aspect, jx, jy = plgdidev
|
187
|
+
printf("device-space window parameters: mar, aspect, jx, jy = %f %f %f %f\n", mar, aspect, jx, jy)
|
188
|
+
if (mar != 0.05 || jx != 0.1 || jy != 0.2)
|
189
|
+
STDERR.puts("plgdidev test failed\n")
|
190
|
+
status = 1
|
191
|
+
end
|
192
|
+
|
193
|
+
plsdiori(1.0)
|
194
|
+
ori = plgdiori
|
195
|
+
printf("ori parameter = %f\n", ori)
|
196
|
+
if (ori != 1.0)
|
197
|
+
STDERR.puts("plgdiori test failed\n")
|
198
|
+
status = 1
|
199
|
+
end
|
200
|
+
|
201
|
+
plsdiplt(0.1, 0.2, 0.9, 0.8)
|
202
|
+
xmin, ymin, xmax, ymax = plgdiplt
|
203
|
+
printf("plot-space window parameters: xmin, ymin, xmax, ymax = %f %f %f %f\n", xmin, ymin, xmax, ymax)
|
204
|
+
if (xmin != 0.1 || xmax != 0.9 || ymin != 0.2 || ymax != 0.8)
|
205
|
+
STDERR.puts("plgdiplt test failed\n")
|
206
|
+
status = 1
|
207
|
+
end
|
208
|
+
|
209
|
+
plsdiplz(0.1, 0.1, 0.9, 0.9)
|
210
|
+
zxmin, zymin, zxmax, zymax = plgdiplt
|
211
|
+
printf("zoomed plot-space window parameters: xmin, ymin, xmax, ymax = %f %f %f %f\n", zxmin, zymin, zxmax, zymax)
|
212
|
+
if ((zxmin - (xmin + (xmax - xmin) * 0.1)).abs > 1.0E-5 ||
|
213
|
+
(zxmax - (xmin + (xmax - xmin) * 0.9)).abs > 1.0E-5 ||
|
214
|
+
(zymin - (ymin + (ymax - ymin) * 0.1)).abs > 1.0E-5 ||
|
215
|
+
(zymax - (ymin + (ymax - ymin) * 0.9)).abs > 1.0E-5)
|
216
|
+
STDERR.puts("plsdiplz test failed\n")
|
217
|
+
status = 1
|
218
|
+
end
|
219
|
+
|
220
|
+
plscolbg(10, 20, 30)
|
221
|
+
r, g, b, = plgcolbg
|
222
|
+
printf("background colour parameters: r, g, b = %d %d %d\n", r, g, b)
|
223
|
+
if (r != 10 || g != 20 || b != 30)
|
224
|
+
STDERR.puts("plgcolbg test failed\n")
|
225
|
+
status = 1
|
226
|
+
end
|
227
|
+
|
228
|
+
plscolbga(20, 30, 40, 0.5)
|
229
|
+
r, g, b, a = plgcolbga
|
230
|
+
printf("background/transparency colour parameters: r, g, b, a = %d %d %d %f\n", r, g, b, a)
|
231
|
+
if (r != 20 || g != 30 || b != 40 || a != 0.5)
|
232
|
+
STDERR.puts("plgcolbga test failed\n")
|
233
|
+
status = 1
|
234
|
+
end
|
235
|
+
|
236
|
+
plend
|
237
|
+
|
238
|
+
exit status
|
data/examples/x32.rb
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$-w = true if $0 == __FILE__
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'plplot'
|
6
|
+
include PLplot
|
7
|
+
|
8
|
+
# Box plot demo.
|
9
|
+
#
|
10
|
+
# Copyright (C) 2008 by FLLL <http://www.flll.jku.at>
|
11
|
+
# Author: Robert Pollak <robert.pollak@jku.at>
|
12
|
+
# Copyright (C) 2009 Andrew Ross
|
13
|
+
#
|
14
|
+
# This file is part of PLplot.
|
15
|
+
#
|
16
|
+
# PLplot is free software; you can redistribute it and/or modify
|
17
|
+
# it under the terms of the GNU General Library Public License as published
|
18
|
+
# by the Free Software Foundation; either version 2 of the License, or
|
19
|
+
# (at your option) any later version.
|
20
|
+
#
|
21
|
+
# PLplot is distributed in the hope that it will be useful,
|
22
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24
|
+
# GNU Library General Public License for more details.
|
25
|
+
#
|
26
|
+
# You should have received a copy of the GNU Library General Public License
|
27
|
+
# along with PLplot; if not, write to the Free Software
|
28
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
29
|
+
|
30
|
+
def plfbox(x, y25, y50, y75, lw, uw )
|
31
|
+
|
32
|
+
spacing = 0.4; # in x axis units
|
33
|
+
|
34
|
+
xmin = x + spacing / 2.0;
|
35
|
+
xmax = x + 1.0 - spacing / 2.0;
|
36
|
+
|
37
|
+
# box
|
38
|
+
|
39
|
+
px = [xmin, xmin, xmax, xmax, xmin]
|
40
|
+
py = [ y25, y75, y75, y25, y25]
|
41
|
+
|
42
|
+
plpsty( 0 );
|
43
|
+
plfill( px, py );
|
44
|
+
plcol0( 1 );
|
45
|
+
pllsty( 1 );
|
46
|
+
plline( px, py );
|
47
|
+
|
48
|
+
|
49
|
+
# median
|
50
|
+
|
51
|
+
mx = [xmin, xmax]
|
52
|
+
my = [ y50, y50];
|
53
|
+
|
54
|
+
pllsty( 1 );
|
55
|
+
plline( mx, my );
|
56
|
+
|
57
|
+
# lower whisker
|
58
|
+
|
59
|
+
xmid = ( xmin + xmax ) / 2.0;
|
60
|
+
xwidth = xmax - xmin;
|
61
|
+
wx = [xmid, xmid]
|
62
|
+
wy = [ lw, y25]
|
63
|
+
|
64
|
+
pllsty( 2 ); # short dashes and gaps
|
65
|
+
plline( wx, wy );
|
66
|
+
|
67
|
+
barx = [xmid - xwidth / 4.0, xmid + xwidth / 4.0]
|
68
|
+
bary = [lw, lw]
|
69
|
+
|
70
|
+
pllsty( 1 );
|
71
|
+
plline( barx, bary );
|
72
|
+
|
73
|
+
# upper whisker
|
74
|
+
|
75
|
+
xmid = ( xmin + xmax ) / 2.0;
|
76
|
+
xwidth = xmax - xmin;
|
77
|
+
wy = [y75, uw]
|
78
|
+
|
79
|
+
pllsty( 2 ) # short dashes and gaps
|
80
|
+
plline( wx, wy );
|
81
|
+
|
82
|
+
bary = [uw, uw]
|
83
|
+
|
84
|
+
pllsty( 1 );
|
85
|
+
plline( barx, bary );
|
86
|
+
end
|
87
|
+
|
88
|
+
#--------------------------------------------------------------------------
|
89
|
+
# Does a box plot.
|
90
|
+
#--------------------------------------------------------------------------
|
91
|
+
|
92
|
+
# quartiles
|
93
|
+
y25= [
|
94
|
+
0.984, 0.980, 0.976, 0.975, 0.973,
|
95
|
+
0.967, 0.974, 0.954, 0.987, 0.991
|
96
|
+
]
|
97
|
+
y50 = [
|
98
|
+
0.994, 0.999, 1.035, 0.995, 1.002,
|
99
|
+
0.997, 1.034, 0.984, 1.007, 1.017
|
100
|
+
]
|
101
|
+
y75 = [
|
102
|
+
1.054, 1.040, 1.066, 1.025, 1.043,
|
103
|
+
1.017, 1.054, 1.004, 1.047, 1.031
|
104
|
+
]
|
105
|
+
|
106
|
+
# lower and upper whisker
|
107
|
+
lw = [
|
108
|
+
0.964, 0.950, 0.926, 0.955, 0.963,
|
109
|
+
0.937, 0.944, 0.924, 0.967, 0.941
|
110
|
+
]
|
111
|
+
|
112
|
+
uw = [
|
113
|
+
1.071, 1.062, 1.093, 1.045, 1.072,
|
114
|
+
1.067, 1.085, 1.024, 1.057, 1.071
|
115
|
+
]
|
116
|
+
|
117
|
+
# outliers
|
118
|
+
outx = [3.50, 6.50]
|
119
|
+
outy = [0.89, 1.09]
|
120
|
+
|
121
|
+
#pos = [0.0, 0.25, 0.5, 0.75, 1.0]
|
122
|
+
#red = [0.0, 0.25, 0.5, 1.0, 1.0]
|
123
|
+
#green = [1.0, 0.5, 0.5, 0.5, 1.0]
|
124
|
+
#blue = [1.0, 1.0, 0.5, 0.25, 0.0]
|
125
|
+
|
126
|
+
# Parse and process command line arguments
|
127
|
+
|
128
|
+
PLOptionParser.parse!
|
129
|
+
|
130
|
+
# Initialize plplot
|
131
|
+
|
132
|
+
plinit
|
133
|
+
|
134
|
+
pladv( 0 );
|
135
|
+
plvsta();
|
136
|
+
|
137
|
+
x0 = 1.0;
|
138
|
+
plwind( x0, x0 + 10, 0.85, 1.15 );
|
139
|
+
plcol0( 1 );
|
140
|
+
plbox( "bc", 1.0, 0, "bcgnst", 0, 0 );
|
141
|
+
pllab( "Group", "Value", "#frPLplot Example 32" );
|
142
|
+
|
143
|
+
# plscmap1l(1,pos,red,green,blue);
|
144
|
+
|
145
|
+
10.times do |i|
|
146
|
+
plcol1( i / 9.0 );
|
147
|
+
plfbox( ( x0 + i ), y25[i], y50[i], y75[i], lw[i], uw[i] );
|
148
|
+
|
149
|
+
string = sprintf( "%d", x0.to_i + i );
|
150
|
+
plmtex( "b", 1.0, ( ( i + 1 ) * 0.1 - 0.05 ), 0.5, string );
|
151
|
+
end
|
152
|
+
|
153
|
+
# some outliers plotted with intermediate-sized circles, see PLplot
|
154
|
+
# example 06 for other possibilities.
|
155
|
+
plpoin( outx, outy, 22 );
|
156
|
+
|
157
|
+
# Don't forget to call plend() to finish off!
|
158
|
+
|
159
|
+
plend
|