Date:2011-02-06 11:31:25 (3 years 6 months ago)
Author:Xiangfu Liu
Commit:868eb3bace27ccc7d823fb0f97bd4acd977bb0b7
Message:rename nanonote-example files

Files: nanonote-example-files/Makefile (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/plplot_examples.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x01.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x02.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x03.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x04.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x05.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x06.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x07.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x08.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x09.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x10.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x11.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x12.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x13.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x14.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x15.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x16.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x17.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x18.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x19.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x20.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x21.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x22.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x23.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x24.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x25.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x26.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x27.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x28.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x29.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x30.lua (1 diff)
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x31.lua (1 diff)
nanonote-example-files/example-files/data/Music/Camille_Saint-Saens_-_introduction_et_rondo_capriccioso,_op._28.ogg (0 diffs)
nanonote-example-files/example-files/data/Music/README (1 diff)
nanonote-example-files/script-files/usr/bin/mtd.nn (1 diff)
nanonote-files/Makefile (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/plplot_examples.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x01.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x02.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x03.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x04.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x05.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x06.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x07.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x08.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x09.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x10.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x11.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x12.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x13.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x14.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x15.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x16.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x17.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x18.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x19.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x20.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x21.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x22.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x23.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x24.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x25.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x26.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x27.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x28.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x29.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x30.lua (1 diff)
nanonote-files/example-files/data/Examples/lua-plplot-examples/x31.lua (1 diff)
nanonote-files/example-files/data/Music/Camille_Saint-Saens_-_introduction_et_rondo_capriccioso,_op._28.ogg (0 diffs)
nanonote-files/example-files/data/Music/README (1 diff)
nanonote-files/script-files/usr/bin/mtd.nn (1 diff)

Change Details

nanonote-example-files/Makefile
1include $(TOPDIR)/rules.mk
2
3PKG_NAME:=nanonote-files
4PKG_VERSION:=1.0
5
6include $(INCLUDE_DIR)/package.mk
7
8define Package/nanonote-files/Default
9    MAINTAINER:="Xiangfu Liu" <xiangfu@sharism.cc>
10    TITLE:=NanoNote Files
11    SECTION:=utils
12    CATEGORY:=Utilities
13endef
14
15define Package/nanonote-example-files
16    $(call Package/nanonote-files/Default)
17    TITLE+=(Example Files)
18endef
19
20define Package/nanonote-script-files
21    $(call Package/nanonote-files/Default)
22    TITLE+=(Script Files)
23endef
24
25define Build/Compile
26endef
27
28define Package/nanonote-example-files/install
29    $(CP) ./example-files/* $(1)/
30endef
31
32define Package/nanonote-script-files/install
33    $(CP) ./script-files/* $(1)/
34endef
35
36$(eval $(call BuildPackage,nanonote-example-files))
37$(eval $(call BuildPackage,nanonote-script-files))
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/plplot_examples.lua
1if string.sub(_VERSION,1,7)=='Lua 5.0' then
2    lib=loadlib('/home/pub/spock/src/qi/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/plplot-5.9.7/bindings/lua/plplotluac.so','luaopen_plplotluac') or
3      loadlib('/home/pub/spock/src/qi/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/plplot-5.9.7/bindings/lua/plplotluac.dll','luaopen_plplotluac') or
4      loadlib('/home/pub/spock/src/qi/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/plplot-5.9.7/bindings/lua/plplotluac.dylib','luaopen_plplotluac')
5    assert(lib)()
6else
7    package.cpath = '/home/pub/spock/src/qi/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/plplot-5.9.7/bindings/lua/?.so;' ..
8                  '/home/pub/spock/src/qi/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/plplot-5.9.7/bindings/lua/?.dll;' ..
9                  '/home/pub/spock/src/qi/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/plplot-5.9.7/bindings/lua/?.dylib;' ..package.cpath
10    require('plplotluac')
11end
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x01.lua
1
2    Simple line plot and multiple windows demo.
3
4  Copyright (C) 2008 Werner Smekal
5
6  This file is part of PLplot.
7
8  PLplot is free software you can redistribute it and/or modify
9  it under the terms of the GNU General Library Public License as published
10  by the Free Software Foundation either version 2 of the License, or
11  (at your option) any later version.
12
13  PLplot is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Library General Public License for more details.
17
18  You should have received a copy of the GNU Library General Public License
19  along with PLplot if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22dofile("plplot_examples.lua")
23
24x = {}
25y = {}
26xs = {}
27ys = {}
28
29fontset = 1
30f_name = ""
31
32
33function plot1(do_test)
34  for i = 1, 60 do
35    x[i] = xoff + xscale * (i) / 60
36    y[i] = yoff + yscale * x[i]^2
37  end
38
39  xmin = x[1]
40  xmax = x[60]
41  ymin = y[1]
42  ymax = y[60]
43
44  for i = 1, 6 do
45    xs[i] = x[(i-1) * 10 + 4]
46    ys[i] = y[(i-1) * 10 + 4]
47  end
48
49  -- Set up the viewport and window using PLENV. The range in X is
50  -- 0.0 to 6.0, and the range in Y is 0.0 to 30.0. The axes are
51  -- scaled separately (just = 0), and we just draw a labelled
52  -- box (axis = 0).
53  pl.col0(1)
54  pl.env(xmin, xmax, ymin, ymax, 0, 0)
55  pl.col0(2)
56  pl.lab("(x)", "(y)", "#frPLplot Example 1 - y=x#u2")
57
58  -- Plot the data points
59  pl.col0(4)
60  pl.poin(xs, ys, 9)
61
62  -- Draw the line through the data
63  pl.col0(3)
64  pl.line(x, y)
65end
66
67
68function plot2()
69  -- Set up the viewport and window using PLENV. The range in X is -2.0 to
70  -- 10.0, and the range in Y is -0.4 to 2.0. The axes are scaled separately
71  --(just = 0), and we draw a box with axes (axis = 1).
72  pl.col0(1)
73  pl.env(-2, 10, -0.4, 1.2, 0, 1)
74  pl.col0(2)
75  pl.lab("(x)", "sin(x)/x", "#frPLplot Example 1 - Sinc Function")
76
77  -- Fill up the arrays
78  for i=1, 100 do
79    x[i] = (i - 20) / 6
80    y[i] = 1
81    if x[i] ~= 0 then y[i] = math.sin(x[i])/x[i] end
82  end
83
84  -- Draw the line
85  pl.col0(3)
86  pl.wid(2)
87  pl.line(x, y)
88  pl.wid(1)
89end
90
91
92function plot3()
93  space0 = { }
94  mark0 = { }
95  space1 = { 1500 }
96  mark1 = { 1500 }
97
98  -- For the final graph we wish to override the default tick intervals, and
99  --so do not use plenv().
100  pl.adv(0)
101
102  -- Use standard viewport, and define X range from 0 to 360 degrees, Y range
103  --from -1.2 to 1.2.
104  pl.vsta()
105  pl.wind(0, 360, -1.2, 1.2)
106
107  -- Draw a box with ticks spaced 60 degrees apart in X, and 0.2 in Y.
108  pl.col0(1)
109  pl.box("bcnst", 60, 2, "bcnstv", 0.2, 2)
110
111  -- Superimpose a dashed line grid, with 1.5 mm marks and spaces.
112  -- plstyl expects a pointer!
113  pl.styl(mark1, space1)
114  pl.col0(2)
115  pl.box("g", 30, 0, "g", 0.2, 0)
116  pl.styl(mark0, space0)
117
118  pl.col0(3)
119  pl.lab("Angle (degrees)", "sine", "#frPLplot Example 1 - Sine function")
120
121  for i=1, 101 do
122    x[i] = 3.6*(i-1)
123    y[i] = math.sin(x[i]*math.pi/180)
124  end
125
126  pl.col0(4)
127  pl.line(x, y)
128end
129
130
131
132
133pl.parseopts(arg, pl.PL_PARSE_FULL)
134
135ver=pl.gver()
136print("PLplot library version: " .. ver)
137
138pl.star(2,2)
139
140if fontset ~= 0 then
141    pl.fontld(1)
142else
143    pl.fontld(0)
144end
145
146xscale = 6
147yscale = 1
148xoff = 0
149yoff = 0
150
151plot1(0)
152
153xscale = 1
154yscale = 0.0014
155yoff = 0.0185
156
157digmax = 5
158pl.syax(digmax, 0)
159
160plot1(1)
161plot2()
162plot3()
163
164if f_name~="" then -- command line option '-save filename'
165  print("The current plot was saved in color Postscript under the name " .. f_name .. ".\n")
166  cur_strm = pl.gstrm() -- get current stream
167  new_strm = pl.mkstrm() -- create a new one
168
169  pl.sfnam(f_name) -- file name
170  pl.sdev("psc") -- device type
171
172  pl.cpstrm(cur_strm, 0) -- copy old stream parameters to new stream
173  pl.replot() -- do the save by replaying the plot buffer
174  pl.plend1() -- finish the device
175
176  pl.sstrm(cur_strm) -- return to previous stream
177end
178
179pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x02.lua
1
2    Multiple window and color map 0 demo.
3
4  Copyright (C) 2008 Werner Smekal
5
6  This file is part of PLplot.
7
8  PLplot is free software you can redistribute it and/or modify
9  it under the terms of the GNU General Library Public License as published
10  by the Free Software Foundation either version 2 of the License, or
11  (at your option) any later version.
12
13  PLplot is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Library General Public License for more details.
17
18  You should have received a copy of the GNU Library General Public License
19  along with PLplot if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22dofile("plplot_examples.lua")
23
24
25function draw_windows(nw, cmap0_offset)
26  pl.schr(0, 3.5)
27  pl.font(4)
28
29  for i = 0, nw-1 do
30    pl.col0(i+cmap0_offset)
31    pl.adv(0)
32    vmin = 0.1
33    vmax = 0.9
34    for j = 0, 2 do
35      pl.wid(j + 1)
36      pl.vpor(vmin, vmax, vmin, vmax)
37      pl.wind(0, 1, 0, 1)
38      pl.box("bc", 0, 0, "bc", 0, 0)
39      vmin = vmin + 0.1
40      vmax = vmax - 0.1
41    end
42    pl.wid(1)
43    pl.ptex(0.5, 0.5, 1, 0, 0.5, tostring(i))
44  end
45end
46
47
48
49function demo1()
50  pl.bop()
51
52  -- Divide screen into 16 regions
53  pl.ssub(4, 4)
54
55  draw_windows(16, 0)
56
57  pl.eop()
58end
59
60
61
62function demo2()
63  -- Set up cmap0
64  -- Use 100 custom colors in addition to base 16
65  r = {}
66  g = {}
67  b = {}
68
69  -- Min & max lightness values
70  lmin = 0.15
71  lmax = 0.85
72
73  pl.bop()
74
75  -- Divide screen into 100 regions
76
77  pl.ssub(10, 10)
78
79  for i = 0, 99 do
80    -- Bounds on HLS, from pl.hlsrgb() commentary --
81    -- hue [0., 360.] degrees
82    -- lightness [0., 1.] magnitude
83    -- saturation [0., 1.] magnitude
84
85    -- Vary hue uniformly from left to right
86    h = (360/10) * math.mod(i, 10)
87
88    -- Vary lightness uniformly from top to bottom, between min & max
89    l = lmin + (lmax - lmin) * math.floor(i/10)/9
90
91    -- Use max saturation
92    s = 1
93
94    r1, g1, b1 = pl.hlsrgb(h, l, s)
95
96    -- Use 255.001 to avoid close truncation decisions in this example.
97    r[i+1+16] = r1 * 255.001
98    g[i+1+16] = g1 * 255.001
99    b[i+1+16] = b1 * 255.001
100  end
101
102  -- Load default cmap0 colors into our custom set
103  for i = 0, 15 do
104    r[i+1], g[i+1], b[i+1] = pl.gcol0(i)
105  end
106
107  -- Now set cmap0 all at once (faster, since fewer driver calls)
108  pl.scmap0(r, g, b)
109
110  draw_windows(100, 16)
111
112  pl.eop()
113end
114
115
116
117pl.parseopts(arg, pl.PL_PARSE_FULL)
118
119pl.init()
120
121demo1()
122demo2()
123
124pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x03.lua
1
2    Polar plot demo.
3
4  Copyright (C) 2008 Werner Smekal
5
6  This file is part of PLplot.
7
8  PLplot is free software you can redistribute it and/or modify
9  it under the terms of the GNU General Library Public License as published
10  by the Free Software Foundation either version 2 of the License, or
11  (at your option) any later version.
12
13  PLplot is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Library General Public License for more details.
17
18  You should have received a copy of the GNU Library General Public License
19  along with PLplot if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22dofile("plplot_examples.lua")
23
24
25x0 = {}
26y0 = {}
27x = {}
28y = {}
29
30dtr = math.pi/180
31for i = 1, 361 do
32  x0[i] = math.cos(dtr * (i-1))
33  y0[i] = math.sin(dtr * (i-1))
34end
35
36
37pl.parseopts(arg, pl.PL_PARSE_FULL)
38
39pl.sori(1)
40
41pl.init()
42
43pl.env(-1.3, 1.3, -1.3, 1.3, 1, -2)
44
45for i = 1, 10 do
46        pl.arc(0, 0, 0.1*i, 0.1*i, 0, 360, 0);
47end
48
49pl.col0(2)
50for i=1, 12 do
51    theta = 30 * (i-1)
52    dx = math.cos(dtr * theta)
53    dy = math.sin(dtr * theta)
54
55  -- Draw radial spokes for polar grid
56
57    pl.join(0, 0, dx, dy)
58
59  -- Write labels for angle
60    if theta < 9.99 then
61      offset = 0.45
62    else
63    if theta < 99.9 then
64      offset = 0.30
65    else
66      offset = 0.15
67    end
68    end
69
70  -- Slightly off zero to avoid floating point logic flips at 90 and 270 deg.
71    if dx >= -0.00001 then
72        pl.ptex(dx, dy, dx, dy, -offset, tostring(math.floor(theta)))
73    else
74        pl.ptex(dx, dy, -dx, -dy, 1.+offset, tostring(math.floor(theta)))
75  end
76end
77
78for i=1, 361 do
79  r = math.sin(dtr * (5*(i-1)))
80  x[i] = x0[i] * r
81  y[i] = y0[i] * r
82end
83pl.col0(3)
84pl.line(x, y)
85
86pl.col0(4)
87pl.mtex("t", 2, 0.5, 0.5, "#frPLplot Example 3 - r(#gh)=sin 5#gh")
88
89pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x04.lua
1
2    Log plot demo.
3    Simple line plot and multiple windows demo.
4
5  Copyright (C) 2008 Werner Smekal
6
7  This file is part of PLplot.
8
9  PLplot is free software you can redistribute it and/or modify
10  it under the terms of the GNU General Library Public License as published
11  by the Free Software Foundation either version 2 of the License, or
12  (at your option) any later version.
13
14  PLplot is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Library General Public License for more details.
18
19  You should have received a copy of the GNU Library General Public License
20  along with PLplot if not, write to the Free Software
21  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
23dofile("plplot_examples.lua")
24
25
26function plot1(type)
27  freql = {}
28  ampl = {}
29  phase = {}
30
31  pl.adv(0)
32
33  -- Set up data for log plot
34  f0 = 1
35  for i=1, 101 do
36    freql[i] = -2 + (i-1) / 20
37    freq = 10^freql[i]
38    ampl[i] = 20 * math.log10(1 / math.sqrt(1 + (freq / f0)^2))
39    phase[i] = -(180 / math.pi) * math.atan(freq / f0)
40  end
41
42  pl.vpor(0.15, 0.85, 0.1, 0.9)
43  pl.wind(-2, 3, -80, 0)
44
45  -- Try different axis and labelling styles.
46  pl.col0(1)
47  if type == 0 then
48    pl.box("bclnst", 0, 0, "bnstv", 0, 0)
49  end
50
51  if type == 1 then
52    pl.box("bcfghlnst", 0, 0, "bcghnstv", 0, 0)
53  end
54
55  -- Plot ampl vs freq
56  pl.col0(2)
57  pl.line(freql, ampl)
58  pl.col0(1)
59  pl.ptex(1.6, -30, 1, -20, 0.5, "-20 dB/decade")
60
61  -- Put labels on
62  pl.col0(1)
63  pl.mtex("b", 3.2, 0.5, 0.5, "Frequency")
64  pl.mtex("t", 2, 0.5, 0.5, "Single Pole Low-Pass Filter")
65  pl.col0(2)
66  pl.mtex("l", 5, 0.5, 0.5, "Amplitude (dB)")
67
68  -- For the gridless case, put phase vs freq on same plot
69  if type == 0 then
70    pl.col0(1)
71    pl.wind(-2, 3, -100, 0)
72    pl.box("", 0, 0, "cmstv", 30, 3)
73    pl.col0(3)
74    pl.line(freql, phase)
75    pl.col0(3)
76    pl.mtex("r", 5, 0.5, 0.5, "Phase shift (degrees)")
77  end
78end
79
80
81
82pl.parseopts(arg, pl.PL_PARSE_FULL)
83
84pl.init()
85pl.font(2)
86
87plot1(0)
88plot1(1)
89
90pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x05.lua
1
2    Histogram demo.
3
4  Copyright (C) 2008 Werner Smekal
5
6  This file is part of PLplot.
7
8  PLplot is free software you can redistribute it and/or modify
9  it under the terms of the GNU General Library Public License as published
10  by the Free Software Foundation either version 2 of the License, or
11  (at your option) any later version.
12
13  PLplot is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Library General Public License for more details.
17
18  You should have received a copy of the GNU Library General Public License
19  along with PLplot if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22dofile("plplot_examples.lua")
23
24
25NPTS=2047
26data = {}
27
28pl.parseopts(arg, pl.PL_PARSE_FULL);
29
30pl.init()
31
32delta = 2.0*math.pi/NPTS
33for i=1, NPTS do
34  data[i] = math.sin((i-1)*delta)
35end
36
37pl.col0(1)
38pl.hist(data, -1.1, 1.1, 44, 0)
39pl.col0(2)
40pl.lab("#frValue", "#frFrequency",
41         "#frPLplot Example 5 - Probability function of Oscillator")
42
43pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x06.lua
1
2    Font demo.
3
4  Copyright (C) 2008 Werner Smekal
5
6  This file is part of PLplot.
7
8  PLplot is free software you can redistribute it and/or modify
9  it under the terms of the GNU General Library Public License as published
10  by the Free Software Foundation either version 2 of the License, or
11  (at your option) any later version.
12
13  PLplot is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Library General Public License for more details.
17
18  You should have received a copy of the GNU Library General Public License
19  along with PLplot if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22dofile("plplot_examples.lua")
23
24
25pl.parseopts(arg, pl.PL_PARSE_FULL)
26
27pl.init()
28
29for kind_font = 0,1 do
30  pl.fontld( kind_font )
31  if kind_font == 0 then
32    maxfont = 1
33  else
34    maxfont = 4
35  end
36
37  for font = 1,maxfont do
38    pl.font( font )
39    pl.adv(0)
40
41    -- Set up viewport and window
42    pl.col0(2)
43    pl.vpor(0.1, 1, 0.1, 0.9)
44    pl.wind(0, 1, 0, 1.3)
45
46    -- Draw the grid using plbox
47    pl.box("bcg", 0.1, 0, "bcg", 0.1, 0)
48
49    -- Write the digits below the frame
50    pl.col0(15)
51    for i=0, 9 do
52      pl.mtex("b", 1.5, (0.1 * i + 0.05), 0.5, tostring(i))
53    end
54
55    k = 0
56    x = {}
57    y ={}
58    for i = 0, 12 do
59      -- Write the digits to the left of the frame
60      pl.mtex("lv", 1, (1 - (2 * i + 1) / 26), 1, tostring(10*i))
61      for j = 0, 9 do
62        x[1] = 0.1 * j + 0.05
63        y[1] = 1.25 - 0.1 * i
64
65        -- Display the symbols
66        if k < 128 then
67          pl.poin(x, y, k)
68        end
69        k = k + 1
70      end
71    end
72
73    if kind_font == 0 then
74      pl.mtex("t", 1.5, 0.5, 0.5, "PLplot Example 6 - plpoin symbols (compact)")
75    else
76      pl.mtex("t", 1.5, 0.5, 0.5, "PLplot Example 6 - plpoin symbols (extended)")
77    end
78  end
79end
80pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x07.lua
1
2    Font demo.
3
4  Copyright (C) 2008 Werner Smekal
5
6  This file is part of PLplot.
7
8  PLplot is free software you can redistribute it and/or modify
9  it under the terms of the GNU General Library Public License as published
10  by the Free Software Foundation either version 2 of the License, or
11  (at your option) any later version.
12
13  PLplot is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Library General Public License for more details.
17
18  You should have received a copy of the GNU Library General Public License
19  along with PLplot if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22dofile("plplot_examples.lua")
23
24base = { 0, 100, 0, 100, 200, 500, 600, 700, 800, 900,
25         2000, 2100, 2200, 2300, 2400, 2500,
26                 2600, 2700, 2800, 2900 }
27
28
29pl.parseopts(arg, pl.PL_PARSE_FULL)
30
31pl.init()
32
33pl.fontld(0)
34for l = 1, 20 do
35
36    if l == 3 then
37        pl.fontld(1)
38    end
39    pl.adv(0)
40
41    -- Set up viewport and window
42    pl.col0(2)
43    pl.vpor(0.15, 0.95, 0.1, 0.9)
44    pl.wind(0, 1, 0, 1)
45
46    -- Draw the grid using plbox
47
48    pl.box("bcg", 0.1, 0, "bcg", 0.1, 0)
49
50    -- Write the digits below the frame
51
52    pl.col0(15)
53    for i = 0, 9 do
54        pl.mtex("b", 1.5, (0.1 * i + 0.05), 0.5, tostring(i))
55    end
56
57    k = 0
58    x = {}
59    y = {}
60    for i = 0, 9 do
61        -- Write the digits to the left of the frame
62        pl.mtex("lv", 1.0, (0.95 - 0.1 * i), 1.0, tostring(base[l] + 10 * i))
63        for j=0, 9 do
64            x[1] = 0.1 * j + 0.05
65            y[1] = 0.95 - 0.1 * i
66
67            -- Display the symbols
68            pl.sym(x, y, base[l] + k)
69            k = k + 1
70        end
71    end
72
73    if l <= 2 then
74        pl.mtex("t", 1.5, 0.5, 0.5, "PLplot Example 7 - PLSYM symbols (compact)")
75    else
76        pl.mtex("t", 1.5, 0.5, 0.5, "PLplot Example 7 - PLSYM symbols (extended)")
77    end
78end
79
80pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x08.lua
1
2    3-d plot demo.
3
4  Copyright (C) 2008 Werner Smekal
5
6  This file is part of PLplot.
7
8  PLplot is free software you can redistribute it and/or modify
9  it under the terms of the GNU General Library Public License as published
10  by the Free Software Foundation either version 2 of the License, or
11  (at your option) any later version.
12
13  PLplot is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Library General Public License for more details.
17
18  You should have received a copy of the GNU Library General Public License
19  along with PLplot if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22dofile("plplot_examples.lua")
23
24
25
26function bit(x,b)
27    return (math.mod(x, 2^b) - math.mod(x,2^(b-1)) > 0)
28end
29
30function lor(x,y)
31    result = 0
32    for p=1,8 do result = result + (((bit(x,p) or bit(y,p)) == true) and 2^(p-1) or 0) end
33    return result
34end
35
36
37
38function cmap1_init(gray)
39  i = { 0, 1 } -- left and right boundary
40
41  if gray ~= 0 then
42    h = { 0, 0 } -- hue -- low: red (arbitrary if s=0), high: red (arbitrary if s=0)
43    l = { 0.5, 1 } -- lightness -- low: half-dark, high: light
44    s = { 0, 0 } -- minimum saturation
45  else
46    h = { 240, 0 } -- blue -> green -> yellow -> red
47    l = { 0.6, 0.6 }
48    s = { 0.8, 0.8 }
49  end
50
51  pl.scmap1n(256)
52  pl.scmap1l(0, i, h, l, s)
53end
54
55
56
57XPTS = 35 -- Data points in x
58YPTS = 46 -- Data points in y
59LEVELS = 10
60
61alt = { 60, 20 }
62az = { 30, 60 }
63
64title = {
65    "#frPLplot Example 8 - Alt=60, Az=30",
66    "#frPLplot Example 8 - Alt=20, Az=60"
67}
68
69clevel = {}
70nlevel = LEVELS
71rosen = 1
72sombrero = 0
73
74pl.parseopts(arg, pl.PL_PARSE_FULL)
75if sombrero ~= 0 then rosen=0 end
76
77pl.init()
78
79x = {}
80y = {}
81z = {}
82
83for i=1, XPTS do
84  x[i] = (i-1-math.floor(XPTS/2)) / math.floor(XPTS/2)
85  if rosen~=0 then x[i]=x[i]*1.5 end
86end
87
88for i=1, YPTS do
89  y[i] = (i-1-math.floor(YPTS/2)) / math.floor(YPTS/2)
90  if rosen~=0 then y[i]=y[i]+0.5 end
91end
92
93for i=1, XPTS do
94  xx = x[i]
95  z[i]= {}
96  for j=1, YPTS do
97    yy = y[j]
98    if rosen~=0 then
99      z[i][j] = (1-xx)^2 + 100*(yy-xx^2)^2
100      -- The log argument may be zero for just the right grid.
101      if z[i][j] > 0 then
102        z[i][j] = math.log(z[i][j])
103      else
104        z[i][j] = -5 -- MAXFLOAT would mess-up up the scale
105      end
106    else
107      r = math.sqrt(xx^2 + yy^2)
108      z[i][j] = math.exp(-r^2) * math.cos(2*math.pi*r)
109    end
110  end
111end
112
113zmax, zmin = pl.MinMax2dGrid(z)
114step = (zmax-zmin)/(nlevel+1)
115for i=1, nlevel do
116  clevel[i] = zmin + step + step*(i-1)
117end
118
119pl.lightsource(1, 1, 1)
120
121for k=1, 2 do
122  for ifshade = 1, 4 do
123    pl.adv(0)
124    pl.vpor(0, 1, 0, 0.9)
125    pl.wind(-1, 1, -0.9, 1.1)
126    pl.col0(3)
127    pl.mtex("t", 1, 0.5, 0.5, title[k])
128    pl.col0(1)
129    if rosen~=0 then
130      pl.w3d(1, 1, 1, -1.5, 1.5, -0.5, 1.5, zmin, zmax, alt[k], az[k])
131    else
132      pl.w3d(1, 1, 1, -1, 1, -1, 1, zmin, zmax, alt[k], az[k])
133    end
134
135    pl.box3("bnstu", "x axis", 0, 0,
136           "bnstu", "y axis", 0, 0,
137           "bcdmnstuv", "z axis", 0, 0)
138    pl.col0(2)
139
140    if ifshade==1 then -- diffuse light surface plot
141      cmap1_init(1)
142      pl.surf3d(x, y, z, 0, clevel)
143    end
144
145    if ifshade==2 then -- magnitude colored plot
146      cmap1_init(0)
147      pl.surf3d(x, y, z, pl.MAG_COLOR, {})
148    end
149
150    if ifshade==3 then -- magnitude colored plot with faceted squares
151      cmap1_init(0)
152      pl.surf3d(x, y, z, lor(pl.MAG_COLOR, pl.FACETED), {})
153    end
154
155    if ifshade==4 then -- magnitude colored plot with contours
156      cmap1_init(0)
157      pl.surf3d(x, y, z, lor(lor(pl.MAG_COLOR, pl.SURF_CONT), pl.BASE_CONT), clevel)
158    end
159  end
160end
161
162pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x09.lua
1
2    Contour plot demo.
3
4  Copyright (C) 2008 Werner Smekal
5
6  This file is part of PLplot.
7
8  PLplot is free software you can redistribute it and/or modify
9  it under the terms of the GNU General Library Public License as published
10  by the Free Software Foundation either version 2 of the License, or
11  (at your option) any later version.
12
13  PLplot is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Library General Public License for more details.
17
18  You should have received a copy of the GNU Library General Public License
19  along with PLplot if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22dofile("plplot_examples.lua")
23
24XPTS = 35 -- Data points in x
25YPTS = 46 -- Data points in y
26
27XSPA = 2/(XPTS-1)
28YSPA = 2/(YPTS-1)
29
30PERIMETERPTS = 100
31RPTS = 40
32THETAPTS = 40
33
34PPERIMETERPTS = 100
35PRPTS = 40
36PTHETAPTS = 64
37PNLEVEL = 20
38
39clevel = { -1, -0.8, -0.6, -0.4, -0.2, 0, 0.2, 0.4, 0.6, 0.8, 1}
40
41tr = { XSPA, 0, -1, 0, YSPA, -1 }
42
43function mypltr(x, y)
44    tx = tr[1] * x + tr[2] * y + tr[3]
45    ty = tr[4] * x + tr[5] * y + tr[6]
46
47    return tx, ty
48end
49
50function polar()
51    px = {}
52    py = {}
53    lev = {}
54
55    pl.env(-1, 1, -1, 1, 0, -2)
56    pl.col0(1)
57
58    --Perimeter
59    for i=1, PERIMETERPTS do
60        t = (2*math.pi/(PERIMETERPTS-1))*(i-1)
61        px[i] = math.cos(t)
62        py[i] = math.sin(t)
63  end
64  pl.line(px, py)
65
66    --create data to be contoured.
67  cgrid2["xg"] = {}
68  cgrid2["yg"] = {}
69  cgrid2["nx"] = RPTS
70  cgrid2["ny"] = THETAPTS
71  z = {}
72
73  for i = 1, RPTS do
74    r = (i-1)/(RPTS-1)
75    cgrid2["xg"][i] = {}
76    cgrid2["yg"][i] = {}
77    z[i] = {}
78    for j = 1, THETAPTS do
79      theta = (2*math.pi/(THETAPTS-1))*(j-1)
80      cgrid2["xg"][i][j] = r*math.cos(theta)
81      cgrid2["yg"][i][j] = r*math.sin(theta)
82      z[i][j] = r
83    end
84  end
85
86  for i = 1, 10 do
87    lev[i] = 0.05 + 0.10*(i-1)
88  end
89
90  pl.col0(2)
91  pl.cont(z, 1, RPTS, 1, THETAPTS, lev, "pltr2", cgrid2)
92  pl.col0(1)
93  pl.lab("", "", "Polar Contour Plot")
94end
95
96
97function f2mnmx(f, nx, ny)
98    fmax = f[1][1]
99    fmin = fmax
100
101    for i=1, nx do
102        for j=1, ny do
103        fmax = math.max(fmax, f[i][j])
104        fmin = math.min(fmin, f[i][j])
105        end
106    end
107
108    return fmin, fmax
109end
110
111
112function potential()
113  clevelneg = {}
114  clevelpos = {}
115  px = {}
116  py = {}
117
118  --create data to be contoured.
119  cgrid2["xg"] = {}
120  cgrid2["yg"] = {}
121  cgrid2["nx"] = PRPTS
122  cgrid2["ny"] = PTHETAPTS
123  z = {}
124
125  for i = 1, PRPTS do
126    r = 0.5 + (i-1)
127    cgrid2["xg"][i] = {}
128    cgrid2["yg"][i] = {}
129    for j = 1, PTHETAPTS do
130      theta = 2*math.pi/(PTHETAPTS-1)*(j-0.5)
131      cgrid2["xg"][i][j] = r*math.cos(theta)
132      cgrid2["yg"][i][j] = r*math.sin(theta)
133    end
134  end
135
136  rmax = PRPTS-0.5
137  xmin, xmax = f2mnmx(cgrid2["xg"], PRPTS, PTHETAPTS)
138  ymin, ymax = f2mnmx(cgrid2["yg"], PRPTS, PTHETAPTS)
139  x0 = (xmin + xmax)/2
140  y0 = (ymin + ymax)/2
141
142  -- Expanded limits
143  peps = 0.05
144  xpmin = xmin - math.abs(xmin)*peps
145  xpmax = xmax + math.abs(xmax)*peps
146  ypmin = ymin - math.abs(ymin)*peps
147  ypmax = ymax + math.abs(ymax)*peps
148
149  -- Potential inside a conducting cylinder (or sphere) by method of images.
150  -- Charge 1 is placed at (d1, d1), with image charge at (d2, d2).
151  -- Charge 2 is placed at (d1, -d1), with image charge at (d2, -d2).
152  -- Also put in smoothing term at small distances.
153  eps = 2
154  q1 = 1
155  d1 = rmax/4
156
157  q1i = - q1*rmax/d1
158  d1i = rmax^2/d1
159
160  q2 = -1
161  d2 = rmax/4
162
163  q2i = - q2*rmax/d2
164  d2i = rmax^2/d2
165
166  for i = 1, PRPTS do
167    z[i] = {}
168    for j = 1, PTHETAPTS do
169      div1 = math.sqrt((cgrid2.xg[i][j]-d1)^2 + (cgrid2.yg[i][j]-d1)^2 + eps^2)
170      div1i = math.sqrt((cgrid2.xg[i][j]-d1i)^2 + (cgrid2.yg[i][j]-d1i)^2 + eps^2)
171      div2 = math.sqrt((cgrid2.xg[i][j]-d2)^2 + (cgrid2.yg[i][j]+d2)^2 + eps^2)
172      div2i = math.sqrt((cgrid2.xg[i][j]-d2i)^2 + (cgrid2.yg[i][j]+d2i)^2 + eps^2)
173      z[i][j] = q1/div1 + q1i/div1i + q2/div2 + q2i/div2i
174    end
175  end
176  zmin, zmax = f2mnmx(z, PRPTS, PTHETAPTS)
177
178  -- Positive and negative contour levels.
179  dz = (zmax-zmin)/PNLEVEL
180  nlevelneg = 1
181  nlevelpos = 1
182  for i = 1, PNLEVEL do
183    clevel = zmin + (i-0.5)*dz
184    if clevel <= 0 then
185      clevelneg[nlevelneg] = clevel
186      nlevelneg = nlevelneg + 1
187    else
188      clevelpos[nlevelpos] = clevel
189      nlevelpos = nlevelpos + 1
190    end
191  end
192
193  -- Colours!
194  ncollin = 11
195  ncolbox = 1
196  ncollab = 2
197
198  -- Finally start plotting this page!
199  pl.adv(0)
200  pl.col0(ncolbox)
201
202  pl.vpas(0.1, 0.9, 0.1, 0.9, 1)
203  pl.wind(xpmin, xpmax, ypmin, ypmax)
204  pl.box("", 0, 0, "", 0, 0)
205
206  pl.col0(ncollin)
207  if nlevelneg>1 then
208    -- Negative contours
209    pl.lsty(2)
210    pl.cont(z, 1, PRPTS, 1, PTHETAPTS, clevelneg, "pltr2", cgrid2)
211  end
212
213  if nlevelpos>1 then
214    -- Positive contours
215    pl.lsty(1)
216    pl.cont(z, 1, PRPTS, 1, PTHETAPTS, clevelpos, "pltr2", cgrid2)
217  end
218
219  -- Draw outer boundary
220  for i = 1, PPERIMETERPTS do
221    t = (2*math.pi/(PPERIMETERPTS-1))*(i-1)
222    px[i] = x0 + rmax*math.cos(t)
223    py[i] = y0 + rmax*math.sin(t)
224  end
225
226  pl.col0(ncolbox)
227  pl.line(px, py)
228
229  pl.col0(ncollab)
230  pl.lab("", "", "Shielded potential of charges in a conducting sphere")
231end
232
233
234mark = { 1500 }
235space = { 1500 }
236
237pl.parseopts(arg, pl.PL_PARSE_FULL)
238
239pl.init()
240
241z = {}
242w = {}
243
244for i = 1, XPTS do
245    xx = (i-1 - math.floor(XPTS/2)) / math.floor(XPTS/2)
246  z[i] = {}
247  w[i] = {}
248    for j = 1, YPTS do
249        yy = (j-1 - math.floor(YPTS/2)) / math.floor(YPTS/2) - 1
250        z[i][j] = xx^2 - yy^2
251        w[i][j] = 2 * xx * yy
252    end
253end
254
255cgrid1 = {}
256cgrid1["xg"] = {}
257cgrid1["yg"] = {}
258cgrid1["nx"] = XPTS
259cgrid1["ny"] = YPTS
260cgrid2 = {}
261cgrid2["xg"] = {}
262cgrid2["yg"] = {}
263cgrid2["nx"] = XPTS
264cgrid2["ny"] = YPTS
265
266for i = 1, XPTS do
267  cgrid2["xg"][i] = {}
268  cgrid2["yg"][i] = {}
269    for j = 1, YPTS do
270    xx, yy = mypltr(i-1, j-1)
271
272    argx = xx * math.pi/2
273    argy = yy * math.pi/2
274    distort = 0.4
275
276    cgrid1["xg"][i] = xx + distort * math.cos(argx)
277    cgrid1["yg"][j] = yy - distort * math.cos(argy)
278
279    cgrid2["xg"][i][j] = xx + distort * math.cos(argx) * math.cos(argy)
280    cgrid2["yg"][i][j] = yy - distort * math.cos(argx) * math.cos(argy)
281  end
282end
283
284pl.setcontlabelformat(4, 3)
285pl.setcontlabelparam(0.006, 0.3, 0.1, 1)
286pl.env(-1, 1, -1, 1, 0, 0)
287pl.col0(2)
288pl.cont(z, 1, XPTS, 1, YPTS, clevel, "mypltr")
289pl.styl(mark, space)
290pl.col0(3)
291pl.cont(w, 1, XPTS, 1, YPTS, clevel, "mypltr")
292pl.styl({}, {})
293pl.col0(1)
294pl.lab("X Coordinate", "Y Coordinate", "Streamlines of flow")
295pl.setcontlabelparam(0.006, 0.3, 0.1, 0)
296
297pl.env(-1, 1, -1, 1, 0, 0)
298pl.col0(2)
299pl.cont(z, 1, XPTS, 1, YPTS, clevel, "pltr1", cgrid1)
300pl.styl(mark, space)
301pl.col0(3)
302pl.cont(w, 1, XPTS, 1, YPTS, clevel, "pltr1", cgrid1)
303pl.styl({}, {})
304pl.col0(1)
305pl.lab("X Coordinate", "Y Coordinate", "Streamlines of flow")
306
307pl.env(-1, 1, -1, 1, 0, 0)
308pl.col0(2)
309pl.cont(z, 1, XPTS, 1, YPTS, clevel, "pltr2", cgrid2)
310
311pl.styl(mark, space)
312pl.col0(3)
313pl.cont(w, 1, XPTS, 1, YPTS, clevel, "pltr2", cgrid2)
314pl.styl({}, {})
315pl.col0(1)
316pl.lab("X Coordinate", "Y Coordinate", "Streamlines of flow")
317
318pl.setcontlabelparam(0.006, 0.3, 0.1, 0)
319polar()
320
321pl.setcontlabelparam(0.006, 0.3, 0.1, 0)
322potential()
323
324pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x10.lua
1
2    Window positioning demo.
3
4  Copyright (C) 2008 Werner Smekal
5
6  This file is part of PLplot.
7
8  PLplot is free software you can redistribute it and/or modify
9  it under the terms of the GNU General Library Public License as published
10  by the Free Software Foundation either version 2 of the License, or
11  (at your option) any later version.
12
13  PLplot is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Library General Public License for more details.
17
18  You should have received a copy of the GNU Library General Public License
19  along with PLplot if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22dofile("plplot_examples.lua")
23
24
25
26pl.parseopts(arg, pl.PL_PARSE_FULL);
27
28pl.init()
29
30pl.adv(0)
31pl.vpor(0.0, 1.0, 0.0, 1.0)
32pl.wind(0.0, 1.0, 0.0, 1.0)
33pl.box("bc", 0.0, 0, "bc", 0.0, 0)
34
35pl.svpa(50.0, 150.0, 50.0, 100.0)
36pl.wind(0.0, 1.0, 0.0, 1.0)
37pl.box("bc", 0.0, 0, "bc", 0.0, 0)
38pl.ptex(0.5, 0.5, 1.0, 0.0, 0.5, "BOX at (50,150,50,100)")
39pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x11.lua
1
2    Mesh plot demo.
3
4  Copyright (C) 2008 Werner Smekal
5
6  This file is part of PLplot.
7
8  PLplot is free software you can redistribute it and/or modify
9  it under the terms of the GNU General Library Public License as published
10  by the Free Software Foundation either version 2 of the License, or
11  (at your option) any later version.
12
13  PLplot is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Library General Public License for more details.
17
18  You should have received a copy of the GNU Library General Public License
19  along with PLplot if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22dofile("plplot_examples.lua")
23
24XPTS = 35 -- Data points in x
25YPTS = 46 -- Data points in y
26LEVELS = 10
27
28opt = { pl.DRAW_LINEXY, pl.DRAW_LINEXY }
29
30alt = { 33, 17 }
31az = { 24, 115 }
32
33title = {
34    "#frPLplot Example 11 - Alt=33, Az=24, Opt=3",
35    "#frPLplot Example 11 - Alt=17, Az=115, Opt=3" }
36
37
38
39function bit(x,b)
40    return (math.mod(x, 2^b) - math.mod(x,2^(b-1)) > 0)
41end
42
43function lor(x,y)
44    result = 0
45    for p=1,8 do result = result + (((bit(x,p) or bit(y,p)) == true) and 2^(p-1) or 0) end
46    return result
47end
48
49
50function cmap1_init()
51  i = { 0, 1 } -- left boundary , right boundary
52  h = { 240, 0 } -- blue -> green -> yellow -> red
53  l = { 0.6, 0.6 }
54  s = { 0.8, 0.8 }
55
56  pl.scmap1n(256)
57  pl.scmap1l(0, i, h, l, s)
58end
59
60
61
62nlevel = LEVELS
63clevel = {}
64
65pl.parseopts(arg, pl.PL_PARSE_FULL)
66
67pl.init()
68
69x = {}
70y = {}
71z = {}
72
73for i=1, XPTS do
74  x[i] = 3 * (i-1-math.floor(XPTS/2)) / math.floor(XPTS/2)
75end
76
77for i=1, YPTS do
78  y[i] = 3 * (i-1-math.floor(YPTS/2)) / math.floor(YPTS/2)
79end
80
81for i=1, XPTS do
82  xx = x[i]
83  z[i] = {}
84  for j=1, YPTS do
85    yy = y[j]
86    z[i][j] = 3 * (1-xx)^2 * math.exp(-xx^2 - (yy+1.)^2) -
87              10 * (xx/5 - xx^3 - yy^5) * math.exp(-xx^2-yy^2) -
88              1/3 * math.exp(-(xx+1)^2 - yy^2)
89
90    -- Jungfraujoch/Interlaken
91    if false then
92      if z[i][j] < -1 then z[i][j] = -1 end
93    end
94  end
95end
96
97zmax, zmin = pl.MinMax2dGrid(z)
98step = (zmax - zmin)/(nlevel+1)
99for i=1, nlevel do
100  clevel[i] = zmin + step + step*(i-1)
101end
102
103cmap1_init()
104for k=1, 2 do
105  for i=1, 4 do
106    pl.adv(0)
107    pl.col0(1)
108    pl.vpor(0, 1, 0, 0.9)
109    pl.wind(-1, 1, -1, 1.5)
110    pl.w3d(1, 1, 1.2, -3, 3, -3, 3, zmin, zmax, alt[k], az[k])
111    pl.box3("bnstu", "x axis", 0, 0,
112            "bnstu", "y axis", 0, 0,
113            "bcdmnstuv", "z axis", 0, 4)
114
115    pl.col0(2)
116
117    -- wireframe plot
118    if i==1 then
119      pl.mesh(x, y, z, opt[k])
120    end
121
122    -- magnitude colored wireframe plot
123    if i==2 then
124      pl.mesh(x, y, z, lor(opt[k], pl.MAG_COLOR))
125    end
126
127    -- magnitude colored wireframe plot with sides
128    if i==3 then
129      pl.plot3d(x, y, z, lor(opt[k], pl.MAG_COLOR), 1)
130    end
131
132    -- magnitude colored wireframe plot with base contour
133    if i==4 then
134      pl.meshc(x, y, z, lor(lor(opt[k], pl.MAG_COLOR), pl.BASE_CONT), clevel)
135    end
136
137    pl.col0(3)
138    pl.mtex("t", 1, 0.5, 0.5, title[k])
139  end
140end
141
142
143pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x12.lua
1
2    Bar chart demo.
3
4  Copyright (C) 2008 Werner Smekal
5
6  This file is part of PLplot.
7
8  PLplot is free software you can redistribute it and/or modify
9  it under the terms of the GNU General Library Public License as published
10  by the Free Software Foundation either version 2 of the License, or
11  (at your option) any later version.
12
13  PLplot is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Library General Public License for more details.
17
18  You should have received a copy of the GNU Library General Public License
19  along with PLplot if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22dofile("plplot_examples.lua")
23
24function pl.fbox(x0, y0)
25  x = { x0, x0, x0+1,x0+1 }
26  y = { 0, y0, y0, 0 }
27
28  pl.fill(x, y);
29  pl.col0(1);
30  pl.lsty(1);
31  pl.line(x, y);
32end
33
34
35y0 = {}
36
37pos = { 0, 0.25, 0.5, 0.75, 1 }
38red = { 0, 0.25, 0.5, 1, 1 }
39green = { 1, 0.5, 0.5, 0.5, 1 }
40blue = { 1, 1, 0.5, 0.25, 0 }
41
42
43
44pl.parseopts(arg, pl.PL_PARSE_FULL);
45
46pl.init()
47
48pl.adv(0)
49pl.vsta()
50pl.wind(1980, 1990, 0, 35)
51pl.box("bc", 1, 0, "bcnv", 10, 0)
52pl.col0(2)
53pl.lab("Year", "Widget Sales (millions)", "#frPLplot Example 12")
54
55y0 = { 5, 15, 12, 24, 28, 30, 20, 8, 12, 3}
56
57pl.scmap1l(1, pos, red, green, blue);
58
59for i=1, 10 do
60    pl.col1((i-1)/9.0);
61    pl.psty(0);
62    pl.fbox((1980+i-1), y0[i]);
63    pl.ptex((1980+i-0.5), (y0[i]+1), 1, 0, 0.5, tostring(y0[i]));
64    pl.mtex("b", 1, (i*0.1-0.05), 0.5, tostring(1980+i-1));
65end
66
67pl.plend();
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x13.lua
1
2    Pie chart demo.
3
4  Copyright (C) 2008 Werner Smekal
5
6  This file is part of PLplot.
7
8  PLplot is free software you can redistribute it and/or modify
9  it under the terms of the GNU General Library Public License as published
10  by the Free Software Foundation either version 2 of the License, or
11  (at your option) any later version.
12
13  PLplot is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Library General Public License for more details.
17
18  You should have received a copy of the GNU Library General Public License
19  along with PLplot if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22dofile("plplot_examples.lua")
23
24text = { "Maurice", "Geoffrey", "Alan",
25         "Rafael", "Vince" }
26
27
28per = { 10, 32, 12, 30, 16 }
29
30
31pl.parseopts(arg, pl.PL_PARSE_FULL);
32
33
34pl.init()
35
36pl.adv(0)
37
38pl.vasp(1)
39pl.wind(0, 10, 0, 10)
40pl.col0(2)
41
42theta0 = 0
43dthet = 1
44for i = 1, 5 do
45  x = { 5 }
46  y = { 5 }
47  j = 2
48  -- n.b. the theta quantities multiplied by 2*math.pi/500 afterward so
49  -- in fact per is interpreted as a percentage.
50    theta1 = theta0 + 5 * per[i]
51    if i == 5 then theta1 = 500 end
52
53    for theta = theta0, theta1, dthet do
54        x[j] = 5 + 3 * math.cos(2*math.pi/500*theta)
55        y[j] = 5 + 3 * math.sin(2*math.pi/500*theta)
56      j = j + 1
57      thetasave=theta
58    end
59    pl.col0(i)
60    pl.psty(math.mod((i + 2), 8) + 1)
61    pl.fill(x, y)
62    pl.col0(1)
63    pl.line(x, y)
64    just = 2*math.pi/500*(theta0 + theta1)/2
65    dx = 0.25 * math.cos(just)
66    dy = 0.25 * math.sin(just)
67    if (theta0 + theta1)<250 or (theta0 + theta1)>750 then
68      just = 0
69    else
70    just = 1
71  end
72
73    pl.ptex((x[(j-1)/2+1] + dx), (y[(j-1)/2+1] + dy), 1, 0, just, text[i]);
74    theta0 = thetasave
75end
76
77pl.font(2)
78pl.schr(0, 1.3)
79pl.ptex(5, 9, 1, 0, 0.5, "Percentage of Sales")
80
81pl.plend()
82
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x14.lua
1
2    Demo of multiple stream/window capability (requires Tk or Tcl-DP).
3
4    Maurice LeBrun
5    IFS, University of Texas at Austin
6
7   Copyright (C) 2009 Werner Smekal
8
9   This file is part of PLplot.
10
11   PLplot is free software you can redistribute it and/or modify
12   it under the terms of the GNU General Library Public License as published
13   by the Free Software Foundation either version 2 of the License, or
14   (at your option) any later version.
15
16   PLplot is distributed in the hope that it will be useful,
17   but WITHOUT ANY WARRANTY without even the implied warranty of
18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19   GNU Library General Public License for more details.
20
21   You should have received a copy of the GNU Library General Public License
22   along with PLplot if not, write to the Free Software
23   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24
25dofile("plplot_examples.lua")
26
27xs = {}
28ys = {}
29space0 = {}
30mark0 = {}
31space1 = { 1500 }
32mark1 = { 1500 }
33
34
35function plot1()
36  x = {}
37  y = {}
38
39  for i = 1, 60 do
40    x[i] = xoff + xscale*i/60
41    y[i] = yoff + yscale*x[i]^2
42  end
43
44  xmin = x[1]
45  xmax = x[60]
46  ymin = y[1]
47  ymax = y[60]
48
49  for i = 1, 6 do
50    xs[i] = x[(i-1)*10 + 4]
51    ys[i] = y[(i-1)*10 + 4]
52  end
53
54  -- Set up the viewport and window using PLENV. The range in X is
55  -- 0.0 to 6.0, and the range in Y is 0.0 to 30.0. The axes are
56  -- scaled separately (just = 0), and we just draw a labelled
57  -- box (axis = 0).
58  pl.col0(1)
59  pl.env(xmin, xmax, ymin, ymax, 0, 0)
60  pl.col0(6)
61  pl.lab("(x)", "(y)", "#frPLplot Example 1 - y=x#u2")
62
63  -- Plot the data points
64  pl.col0(9)
65  pl.poin(xs, ys, 9)
66
67  -- Draw the line through the data
68  pl.col0(4)
69  pl.line(x, y)
70  pl.flush()
71end
72
73
74function plot2()
75  x = {}
76  y = {}
77
78  -- Set up the viewport and window using PLENV. The range in X is -2.0 to
79  -- 10.0, and the range in Y is -0.4 to 2.0. The axes are scaled separately
80  -- (just = 0), and we draw a box with axes (axis = 1).
81  pl.col0(1)
82  pl.env(-2, 10, -0.4, 1.2, 0, 1)
83  pl.col0(2)
84  pl.lab("(x)", "sin(x)/x", "#frPLplot Example 1 - Sinc Function")
85
86  -- Fill up the arrays
87  for i = 1, 100 do
88    x[i] = (i-20)/6
89    y[i] = 1
90    if x[i]~=0 then
91      y[i] = math.sin(x[i])/x[i]
92    end
93  end
94
95  -- Draw the line
96  pl.col0(3)
97  pl.line(x, y)
98  pl.flush()
99end
100
101
102function plot3()
103  x = {}
104  y = {}
105
106  -- For the final graph we wish to override the default tick intervals, and
107  -- so do not use PLENV
108  pl.adv(0)
109
110  -- Use standard viewport, and define X range from 0 to 360 degrees, Y range
111  -- from -1.2 to 1.2.
112  pl.vsta()
113  pl.wind(0, 360, -1.2, 1.2)
114
115  -- Draw a box with ticks spaced 60 degrees apart in X, and 0.2 in Y.
116  pl.col0(1)
117  pl.box("bcnst", 60, 2, "bcnstv", 0.2, 2)
118
119  -- Superimpose a dashed line grid, with 1.5 mm marks and spaces. plstyl
120  -- expects a pointer!!
121  pl.styl(mark1, space1)
122  pl.col0(2)
123  pl.box("g", 30, 0, "g", 0.2, 0)
124  pl.styl(mark0, space0)
125
126  pl.col0(3)
127  pl.lab("Angle (degrees)", "sine", "#frPLplot Example 1 - Sine function")
128
129  for i = 1, 101 do
130    x[i] = 3.6 * (i-1)
131    y[i] = math.sin(x[i]*math.pi/180)
132  end
133
134  pl.col0(4)
135  pl.line(x, y)
136  pl.flush()
137end
138
139
140function plot4()
141  x0 = {}
142  y0 = {}
143  x = {}
144  y = {}
145
146  dtr = math.pi/180
147  for i = 1, 361 do
148    x0[i] = math.cos(dtr*(i-1))
149    y0[i] = math.sin(dtr*(i-1))
150  end
151
152  -- Set up viewport and window, but do not draw box
153  pl.env(-1.3, 1.3, -1.3, 1.3, 1, -2)
154  for i = 1, 10 do
155      for j = 1, 361 do
156        x[j] = 0.1*i*x0[j]
157        y[j] = 0.1*i*y0[j]
158    end
159
160    -- Draw circles for polar grid
161      pl.line(x, y)
162  end
163
164  pl.col0(2)
165  for i = 1, 12 do
166    theta = 30.0 * (i-1)
167    dx = math.cos(dtr * theta)
168    dy = math.sin(dtr * theta)
169
170    -- Draw radial spokes for polar grid
171    pl.join(0, 0, dx, dy)
172
173    -- Write labels for angle
174    -- Slightly off zero to avoid floating point logic flips at 90 and 270 deg.
175    if dx>=-0.00001 then
176      pl.ptex(dx, dy, dx, dy, -0.15, tostring(theta))
177    else
178      pl.ptex(dx, dy, -dx, -dy, 1.15, tostring(theta))
179    end
180  end
181
182  x = {}
183  y = {}
184
185  -- Draw the graph
186  for i = 1, 361 do
187    r = math.sin(dtr * (5*(i-1)))
188    x[i] = x0[i] * r
189    y[i] = y0[i] * r
190  end
191
192  pl.col0(3)
193  pl.line(x, y)
194
195  pl.col0(4)
196  pl.mtex("t", 2, 0.5, 0.5, "#frPLplot Example 3 - r(#gh)=sin 5#gh")
197  pl.flush()
198end
199
200
201XPTS = 35
202YPTS = 46
203XSPA = 2/(XPTS-1)
204YSPA = 2/(YPTS-1)
205
206tr = { XSPA, 0, -1, 0, YSPA, -1 }
207
208function mypltr(x, y)
209  tx = tr[1]*x + tr[2]*y + tr[3]
210  ty = tr[4]*x + tr[5]*y + tr[6]
211
212  return tx, ty
213end
214
215clevel = { -1, -.8, -.6, -.4, -.2, 0, .2, .4, .6, .8, 1 }
216
217function plot5()
218  mark = { 1500 }
219  space = { 1500 }
220
221  -- Set up function arrays
222  z = {}
223  w = {}
224
225  for i = 1, XPTS do
226      xx = (i-1-math.floor(XPTS/2))/math.floor(XPTS/2)
227    z[i] = {}
228    w[i] = {}
229    for j = 1, YPTS do
230      yy = (j-1-math.floor(YPTS/2))/math.floor(YPTS/2)-1
231      z[i][j] = xx * xx - yy * yy
232      w[i][j] = 2 * xx * yy
233    end
234  end
235
236  pl.env(-1, 1, -1, 1, 0, 0)
237  pl.col0(2)
238  pl.cont(z, 1, XPTS, 1, YPTS, clevel, "mypltr")
239  pl.styl(mark, space)
240  pl.col0(3)
241  pl.cont(w, 1, XPTS, 1, YPTS, clevel, "mypltr")
242  pl.col0(1)
243  pl.lab("X Coordinate", "Y Coordinate", "Streamlines of flow")
244  pl.flush()
245end
246
247
248
249geometry_master = "500x410+100+200"
250geometry_slave = "500x410+650+200"
251
252pl.parseopts(arg, pl.PL_PARSE_FULL)
253
254xp0, yp0, xleng0, yleng0, xoff0, yoff0 = pl.gpage()
255valid_geometry = xleng0>0 and yleng0>0
256
257if valid_geometry==true then
258  pl.spage(xp0, yp0, xleng0, yleng0, xoff0, yoff0)
259else
260  pl.setopt("geometry", geometry_master)
261end
262
263pl.ssub(2, 2)
264pl.init()
265
266driver = pl.gdev()
267fam, num, bmax = pl.gfam()
268
269print("Demo of multiple output streams via the " .. driver .." driver.")
270print("Running with the second stream as slave to the first.\n")
271
272pl.sstrm(1)
273
274if valid_geometry==true then
275  pl.spage(xp0, yp0, xleng0, yleng0, xoff0, yoff0)
276else
277  pl.setopt("geometry", geometry_slave)
278end
279
280pl.spause(0)
281pl.sdev(driver)
282pl.sfam(fam,num,bmax)
283
284pl.setopt("fflen", "2")
285pl.init()
286
287pl.sstrm(0)
288
289xscale = 6
290yscale = 1
291xoff = 0
292yoff = 0
293plot1()
294
295xscale = 1
296yscale = 1e6
297plot1()
298
299xscale = 1.
300yscale = 1.e-6
301digmax = 2
302pl.syax(digmax, 0)
303plot1()
304
305xscale = 1
306yscale = 0.0014
307yoff = 0.0185
308digmax = 5
309pl.syax(digmax, 0)
310plot1()
311
312pl.sstrm(1)
313plot4()
314pl.eop()
315
316pl.sstrm(0)
317plot2()
318plot3()
319
320pl.sstrm(1)
321plot5()
322pl.eop()
323
324pl.sstrm(0)
325pl.eop()
326
327pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x15.lua
1
2    Shade plot demo.
3
4  Copyright (C) 2008 Werner Smekal
5
6  This file is part of PLplot.
7
8  PLplot is free software you can redistribute it and/or modify
9  it under the terms of the GNU General Library Public License as published
10  by the Free Software Foundation either version 2 of the License, or
11  (at your option) any later version.
12
13  PLplot is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Library General Public License for more details.
17
18  You should have received a copy of the GNU Library General Public License
19  along with PLplot if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22dofile("plplot_examples.lua")
23
24XPTS = 35 -- Data points in x
25YPTS = 46 -- Data points in y
26
27z = {}
28
29
30
31function cmap1_init1()
32  i = { 0, 0,45, 0.55, 1 } -- left boundary, just before center,
33                            -- just after center, right boundary
34  h = { 260, 260, 20, 20 } -- hue -- low: blue-violet, only change as we go over vertex
35                            -- hue -- high: red, keep fixed
36  l = { 0.5, 0, 0, 0.5 } -- lightness -- low, lightness -- center
37                          -- lightness -- center, lightness -- high
38  s = { 1, 1, 1, 1 } -- maximum saturation
39
40  pl.scmap1l(0, i, h, l, s)
41end
42
43
44
45function cmap1_init2()
46  i = { 0, 0.45, 0.55, 1 } -- left boundary, just before center,
47                            -- just after center, right boundary
48  h = { 260, 260, 20, 20 } -- hue -- low: blue-violet, only change as we go over vertex
49                            -- hue -- high: red, keep fixed
50  l = { 0.6, 0, 0, 0.6 } -- lightness -- low, lightness -- center
51                          -- lightness -- center, lightness -- high
52  s = { 1, 0.5, 0.5, 1 } -- saturation -- low, saturation -- center
53                          -- saturation -- center, saturation -- high
54
55  pl.scmap1l(0, i, h, l, s)
56end
57
58
59
60function plot1()
61  sh_cmap = 0
62
63  pl.adv(0)
64  pl.vpor(0.1, 0.9, 0.1, 0.9)
65  pl.wind(-1, 1, -1, 1)
66
67  -- Plot using identity transform
68  shade_min = zmin + (zmax-zmin)*0.4
69  shade_max = zmin + (zmax-zmin)*0.6
70  sh_color = 7
71  sh_width = 2
72  min_color = 9
73  max_color = 2
74  min_width = 2
75  max_width = 2
76
77  pl.psty(8)
78  pl.shade(z, -1, 1, -1, 1, shade_min, shade_max, sh_cmap, sh_color, sh_width,
79            min_color, min_width, max_color, max_width, 1)
80
81  pl.col0(1)
82  pl.box("bcnst", 0, 0, "bcnstv", 0, 0)
83  pl.col0(2)
84  pl.lab("distance", "altitude", "Bogon flux")
85end
86
87
88
89function plot2()
90  sh_cmap = 0
91  min_color = 0
92  min_width = 0
93  max_color = 0
94  max_width = 0
95
96  inc = { {450}, {-450}, {0}, {900}, {300},
97          {450,-450}, {0, 900}, {0, 450}, {450, -450}, {0, 900} }
98  del = { {2000}, {2000}, {2000}, {2000}, {2000},
99          {2000, 2000}, {2000, 2000}, {2000, 2000}, {4000, 4000}, {4000, 2000} }
100
101  sh_width = 2
102
103  pl.adv(0)
104  pl.vpor(0.1, 0.9, 0.1, 0.9)
105  pl.wind(-1, 1, -1, 1)
106
107  -- Plot using identity transform
108
109  for i = 1, 10 do
110    shade_min = zmin + (zmax - zmin) * (i-1)/10
111    shade_max = zmin + (zmax - zmin) * i/10
112    sh_color = i+5
113    pl.pat(inc[i], del[i])
114
115    pl.shade(z, -1, 1, -1, 1, shade_min, shade_max, sh_cmap, sh_color, sh_width,
116             min_color, min_width, max_color, max_width, 1)
117  end
118
119  pl.col0(1)
120  pl.box("bcnst", 0, 0, "bcnstv", 0, 0)
121  pl.col0(2)
122  pl.lab("distance", "altitude", "Bogon flux")
123end
124
125
126
127function plot3()
128  xx = { {-1, 1, 1, -1, -1}, {-1, 1, 1, -1, -1} }
129  yy = { {1, 1, 0, 0, 1}, {-1, -1, 0, 0, -1} }
130  zz = { {0, 0, 1, 1, 0}, {0, 0, 1, 1, 0} }
131
132  pl.adv(0)
133  pl.vpor(0.1, 0.9, 0.1, 0.9)
134  pl.wind(-1, 1, -1, 1.)
135  pl.w3d(1, 1, 1, -1, 1, -1, 1, 0, 1.5, 30, -40)
136
137  -- Plot using identity transform
138  pl.col0(1)
139  pl.box3("bntu", "X", 0, 0, "bntu", "Y", 0, 0, "bcdfntu", "Z", 0.5, 0)
140  pl.col0(2)
141  pl.lab("","","3-d polygon filling")
142
143  pl.col0(3)
144  pl.psty(1)
145  pl.line3(xx[1], yy[1], zz[1])
146  pl.fill3(xx[1], yy[1], zz[1])
147  pl.psty(2)
148  pl.line3(xx[2], yy[2], zz[2])
149  pl.fill3(xx[2], yy[2], zz[2])
150end
151
152
153
154function f2mnmx(f, nx, ny)
155    fmax = f[1][1]
156    fmin = fmax
157
158    for i=1, nx do
159        for j=1, ny do
160        fmax = math.max(fmax, f[i][j])
161        fmin = math.min(fmin, f[i][j])
162        end
163    end
164
165    return fmin, fmax
166end
167
168
169pl.parseopts(arg, pl.PL_PARSE_FULL)
170
171cmap1_init2()
172
173pl.init()
174
175for i=1, XPTS do
176    xx = ((i-1) - math.floor(XPTS/2))/math.floor(XPTS/2)
177  z[i] = {}
178    for j = 1, YPTS do
179    yy = ((j-1) - math.floor(YPTS/2))/math.floor(YPTS/2) - 1
180    z[i][j] = xx^2 - yy^2 + (xx - yy)/(xx^2+yy^2 + 0.1)
181    end
182end
183zmin, zmax = f2mnmx(z, XPTS, YPTS)
184
185plot1()
186plot2()
187plot3()
188
189pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x16.lua
1
2    plshade demo, using color fill.
3
4  Copyright (C) 2008 Werner Smekal
5
6  This file is part of PLplot.
7
8  PLplot is free software you can redistribute it and/or modify
9  it under the terms of the GNU General Library Public License as published
10  by the Free Software Foundation either version 2 of the License, or
11  (at your option) any later version.
12
13  PLplot is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Library General Public License for more details.
17
18  You should have received a copy of the GNU Library General Public License
19  along with PLplot if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22dofile("plplot_examples.lua")
23
24ns = 20 -- Default number of shade levels
25nx = 35 -- Default number of data points in x
26ny = 46 -- Default number of data points in y
27exclude = 0 -- By default do not plot a page illustrating
28              -- exclusion. API is probably going to change
29              -- anyway, and cannot be reproduced by any
30                      -- front end other than the C one.
31
32PERIMETERPTS = 100
33
34tr = {}
35
36function mypltr(x, y)
37    tx = tr[1] * x + tr[2] * y + tr[3]
38    ty = tr[4] * x + tr[5] * y + tr[6]
39
40    return tx, ty
41end
42
43function f2mnmx(f, nx, ny)
44  fmax = f[1][1]
45  fmin = fmax
46
47  for i = 1, nx do
48    for j = 1, ny do
49      fmax = math.max(fmax, f[i][j])
50      fmin = math.min(fmin, f[i][j])
51    end
52  end
53
54  return fmin, fmax
55end
56
57
58function zdefined(x, y)
59  z = math.sqrt(x^2 + y^2)
60
61  return z<0.4 or z>0.6
62end
63
64
65
66px = {}
67py = {}
68
69fill_width = 2
70cont_color = 0
71cont_width = 0
72
73pl.parseopts(arg, pl.PL_PARSE_FULL)
74
75pl.spal0("cmap0_black_on_white.pal");
76pl.spal1("cmap1_gray.pal",1);
77
78pl.scmap0n(3)
79
80pl.init()
81
82tr = { 2/(nx-1), 0, -1, 0, 2/(ny-1), -1 }
83
84clevel = {}
85shedge = {}
86z = {}
87w = {}
88
89for i = 1, nx do
90    x = (i-1 - math.floor(nx/2))/math.floor(nx/2)
91  z[i] = {}
92  w[i] = {}
93    for j = 1, ny do
94    y = (j-1 - math.floor(ny/2))/math.floor(ny/2)-1
95    z[i][j] = -math.sin(7*x) * math.cos(7*y) + x^2 - y^2
96    w[i][j] = -math.cos(7*x) * math.sin(7*y) + 2*x*y
97    end
98end
99
100zmin, zmax = f2mnmx(z, nx, ny)
101for i = 1, ns do
102    clevel[i] = zmin + (zmax-zmin)*(i-0.5)/ns
103end
104
105for i = 1, ns+1 do
106    shedge[i] = zmin + (zmax-zmin)*(i-1)/ns
107end
108
109cgrid1 = {}
110cgrid1["xg"] = {}
111cgrid1["yg"] = {}
112cgrid1["nx"] = nx
113cgrid1["ny"] = ny
114
115cgrid2 = {}
116cgrid2["xg"] = {}
117cgrid2["yg"] = {}
118cgrid2["nx"] = nx
119cgrid2["ny"] = ny
120
121for i = 1, nx do
122  cgrid2["xg"][i] = {}
123  cgrid2["yg"][i] = {}
124    for j = 1, ny do
125    x, y = mypltr(i-1, j-1)
126
127    argx = x*math.pi/2
128    argy = y*math.pi/2
129    distort = 0.4
130
131    cgrid1["xg"][i] = x + distort * math.cos(argx)
132    cgrid1["yg"][j] = y - distort * math.cos(argy)
133
134    cgrid2["xg"][i][j] = x + distort * math.cos(argx) * math.cos(argy)
135    cgrid2["yg"][i][j] = y - distort * math.cos(argx) * math.cos(argy)
136  end
137end
138
139pl.adv(0)
140pl.vpor(0.1, 0.9, 0.1, 0.9)
141pl.wind(-1, 1, -1, 1)
142
143pl.psty(0)
144
145pl.shades(z, -1, 1, -1, 1, shedge, fill_width, cont_color, cont_width, 1)
146
147pl.col0(1)
148pl.box("bcnst", 0, 0, "bcnstv", 0, 0)
149pl.col0(2)
150
151pl.lab("distance", "altitude", "Bogon density")
152
153
154pl.spal0("cmap0_black_on_white.pal");
155pl.spal1("cmap1_blue_yellow.pal",1);
156
157pl.scmap0n(3);
158
159pl.adv(0)
160pl.vpor(0.1, 0.9, 0.1, 0.9)
161pl.wind(-1, 1, -1, 1)
162
163pl.psty(0)
164
165pl.shades(z, -1, 1, -1, 1, shedge, fill_width, cont_color, cont_width, 1, "pltr1", cgrid1)
166
167pl.col0(1)
168pl.box("bcnst", 0, 0, "bcnstv", 0, 0)
169pl.col0(2)
170pl.lab("distance", "altitude", "Bogon density")
171
172
173pl.spal0("cmap0_black_on_white.pal");
174pl.spal1("cmap1_blue_red.pal",1);
175
176pl.scmap0n(3);
177
178pl.adv(0)
179pl.vpor(0.1, 0.9, 0.1, 0.9)
180pl.wind(-1, 1, -1, 1)
181
182pl.psty(0)
183
184pl.shades(z, -1, 1, -1, 1, shedge, fill_width, cont_color, cont_width, 0, "pltr2", cgrid2)
185
186pl.col0(1)
187pl.box("bcnst", 0, 0, "bcnstv", 0, 0)
188pl.col0(2)
189pl.cont(w, 1, nx, 1, ny, clevel, "pltr2", cgrid2)
190
191pl.lab("distance", "altitude", "Bogon density, with streamlines")
192
193
194pl.spal0("");
195pl.spal1("",1);
196
197pl.scmap0n(3);
198
199pl.adv(0)
200pl.vpor(0.1, 0.9, 0.1, 0.9)
201pl.wind(-1, 1, -1, 1)
202
203pl.psty(0)
204
205pl.shades(z, -1, 1, -1, 1, shedge, fill_width, 2, 3, 0, "pltr2", cgrid2)
206
207pl.col0(1)
208pl.box("bcnst", 0, 0, "bcnstv", 0, 0)
209pl.col0(2)
210
211pl.lab("distance", "altitude", "Bogon density")
212
213
214if exclude~=0 then
215
216    -- Load colour palettes
217  pl.spal0("cmap0_black_on_white.pal");
218  pl.spal1("cmap1_gray.pal",1);
219
220    -- Reduce colors in cmap 0 so that cmap 1 is useful on a 16-color display
221  pl.scmap0n(3);
222
223  pl.adv(0)
224  pl.vpor(0.1, 0.9, 0.1, 0.9)
225  pl.wind(-1, 1, -1, 1)
226
227  plpsty(0)
228
229  pl.shades(z, zdefined, -1, 1, -1, 1, shedge, fill_width, cont_color, cont_width,
230            0, "pltr2", cgrid2)
231
232  pl.col0(1)
233  pl.box("bcnst", 0, 0, "bcnstv", 0, 0)
234
235  pl.lab("distance", "altitude", "Bogon density with exclusion")
236end
237
238
239pl.spal0("cmap0_black_on_white.pal");
240pl.spal1("cmap1_gray.pal",1);
241
242pl.scmap0n(3);
243
244pl.adv(0)
245pl.vpor(.1, .9, .1, .9)
246pl.wind(-1, 1, -1, 1)
247
248pl.psty(0)
249
250for i = 1, nx do
251  r = (i-1)/(nx-1)
252    for j = 1, ny do
253       t = 2*math.pi/(ny-1)*(j-1)
254       cgrid2["xg"][i][j] = r*math.cos(t)
255       cgrid2["yg"][i][j] = r*math.sin(t)
256       z[i][j] = math.exp(-r^2)*math.cos(5*math.pi*r)*math.cos(5*t)
257    end
258end
259
260zmin, zmax = f2mnmx(z, nx, ny)
261
262for i = 1, ns+1 do
263    shedge[i] = zmin + (zmax-zmin)*(i-1)/ns
264end
265
266pl.shades(z, -1, 1, -1, 1, shedge, fill_width, cont_color, cont_width, 0, "pltr2", cgrid2)
267
268for i = 1, PERIMETERPTS do
269   t = 2*math.pi/(PERIMETERPTS-1)*(i-1)
270   px[i] = math.cos(t)
271   py[i] = math.sin(t)
272end
273pl.col0(1)
274pl.line(px, py)
275
276pl.col0(2)
277pl.lab( "", "", "Tokamak Bogon Instability" )
278
279pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x17.lua
1
2    Plots a simple stripchart with four pens.
3
4  Copyright (C) 2008 Werner Smekal
5
6  This file is part of PLplot.
7
8  PLplot is free software you can redistribute it and/or modify
9  it under the terms of the GNU General Library Public License as published
10  by the Free Software Foundation either version 2 of the License, or
11  (at your option) any later version.
12
13  PLplot is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Library General Public License for more details.
17
18  You should have received a copy of the GNU Library General Public License
19  along with PLplot if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22
23dofile("plplot_examples.lua")
24
25
26
27nsteps = 1000
28colline = {}
29legline = {}
30
31pl.parseopts(arg, pl.PL_PARSE_FULL)
32
33
34ymin = -0.1
35ymax = 0.1
36
37tmin = 0
38tmax = 10
39tjump = 0.3 -- percentage of plot to jump
40
41colbox = 1
42collab = 3
43styline = { 2, 3, 4, 5 } -- line style
44colline = { 2, 3, 4, 5 } -- pens color
45
46legline= { "sum", "sin", "sin*noi", "sin+noi" } -- pens legend
47
48xlab = 0 -- legend position
49ylab = 0.25
50
51autoy = 1 -- autoscale y
52acc = 1 -- don't scrip, accumulate
53
54pl.init()
55
56pl.adv(0)
57pl.vsta()
58
59id1 = pl.stripc("bcnst", "bcnstv",
60   tmin, tmax, tjump, ymin, ymax,
61   xlab, ylab,
62   autoy, acc,
63   colbox, collab,
64   colline, styline, legline,
65   "t", "", "Strip chart demo")
66
67autoy = 0 -- autoscale y
68acc = 1 -- accumulate
69
70
71y1 = 0
72y2 = 0
73y3 = 0
74y4 = 0
75dt = 0.1
76
77for n = 0, nsteps-1 do
78    for i = 0, 200000 do end
79    t = n * dt
80    noise = pl.randd() - 0.5
81    y1 = y1 + noise
82    y2 = math.sin(t*math.pi/18)
83    y3 = y2 * noise
84    y4 = y2 + noise/3
85
86  -- There is no need for all pens to have the same number of
87  -- points or beeing equally time spaced.
88    if math.mod(n, 2)~=0 then pl.stripa(id1, 0, t, y1) end
89    if math.mod(n, 3)~=0 then pl.stripa(id1, 1, t, y2) end
90    if math.mod(n, 4)~=0 then pl.stripa(id1, 2, t, y3) end
91    if math.mod(n, 5)~=0 then pl.stripa(id1, 3, t, y4) end
92end
93
94pl.stripd(id1)
95pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x18.lua
1
2    3-d line and point plot demo. Adapted from x08c.c.
3
4  Copyright (C) 2008 Werner Smekal
5
6  This file is part of PLplot.
7
8  PLplot is free software you can redistribute it and/or modify
9  it under the terms of the GNU General Library Public License as published
10  by the Free Software Foundation either version 2 of the License, or
11  (at your option) any later version.
12
13  PLplot is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Library General Public License for more details.
17
18  You should have received a copy of the GNU Library General Public License
19  along with PLplot if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22dofile("plplot_examples.lua")
23
24function test_poly(k)
25  draw= { { 1, 1, 1, 1 },
26          { 1, 0, 1, 0 },
27          { 0, 1, 0, 1 },
28          { 1, 1, 0, 0 } }
29
30  x = {}
31  y = {}
32  z = {}
33
34  pl.adv(0)
35  pl.vpor(0, 1, 0, 0.9)
36  pl.wind(-1, 1, -0.9, 1.1)
37  pl.col0(1)
38  pl.w3d(1, 1, 1, -1, 1, -1, 1, -1, 1, alt[k], az[k])
39  pl.box3("bnstu", "x axis", 0, 0,
40          "bnstu", "y axis", 0, 0,
41          "bcdmnstuv", "z axis", 0, 0)
42
43  pl.col0(2)
44
45  -- x = r sin(phi) cos(theta)
46  -- y = r sin(phi) sin(theta)
47  -- z = r cos(phi)
48  -- r = 1 :=)
49
50  for i=0, 19 do
51    for j=0, 19 do
52        x[1] = math.sin( math.pi*j/20.1 ) * math.cos( 2*math.pi*i/20 )
53        y[1] = math.sin( math.pi*j/20.1 ) * math.sin( 2*math.pi*i/20 )
54        z[1] = math.cos( math.pi*j/20.1 )
55
56        x[2] = math.sin( math.pi*(j+1)/20.1 ) * math.cos( 2*math.pi*i/20 )
57        y[2] = math.sin( math.pi*(j+1)/20.1 ) * math.sin( 2*math.pi*i/20 )
58        z[2] = math.cos( math.pi*(j+1)/20.1 )
59
60        x[3] = math.sin( math.pi*(j+1)/20.1 ) * math.cos( 2*math.pi*(i+1)/20 )
61        y[3] = math.sin( math.pi*(j+1)/20.1 ) * math.sin( 2*math.pi*(i+1)/20 )
62        z[3] = math.cos( math.pi*(j+1)/20.1 )
63
64        x[4] = math.sin( math.pi*j/20.1 ) * math.cos( 2*math.pi*(i+1)/20 )
65        y[4] = math.sin( math.pi*j/20.1 ) * math.sin( 2*math.pi*(i+1)/20 )
66        z[4] = math.cos( math.pi*j/20.1 )
67
68        x[5] = math.sin( math.pi*j/20.1 ) * math.cos( 2*math.pi*i/20 )
69        y[5] = math.sin( math.pi*j/20.1 ) * math.sin( 2*math.pi*i/20 )
70        z[5] = math.cos( math.pi*j/20.1 )
71
72        pl.poly3( x, y, z, draw[k], 1 )
73    end
74  end
75
76  pl.col0(3)
77  pl.mtex("t", 1, 0.5, 0.5, "unit radius sphere" )
78end
79
80
81
82NPTS = 1000
83opt = { 1, 0, 1, 0 }
84alt = { 20, 35, 50, 65 }
85az = { 30, 40, 50, 60 }
86
87
88pl.parseopts(arg, pl.PL_PARSE_FULL)
89
90pl.init()
91
92for k=1, 4 do
93    test_poly(k)
94end
95
96x = {}
97y = {}
98z = {}
99
100for i=1, NPTS do
101  z[i] = -1 + 2*(i-1)/NPTS
102
103  -- Pick one ...
104  -- r = 1 - (i-1) / NPTS
105  r = z[i]
106
107  x[i] = r * math.cos( 12*math.pi*(i-1)/NPTS )
108  y[i] = r * math.sin( 12*math.pi*(i-1)/NPTS )
109end
110
111for k=1, 4 do
112    pl.adv(0)
113    pl.vpor(0, 1, 0, 0.9)
114    pl.wind(-1, 1, -0.9, 1.1)
115    pl.col0(1)
116    pl.w3d(1, 1, 1, -1, 1, -1, 1, -1, 1, alt[k], az[k])
117    pl.box3("bnstu", "x axis", 0, 0,
118            "bnstu", "y axis", 0, 0,
119            "bcdmnstuv", "z axis", 0, 0)
120
121    pl.col0(2)
122
123    if opt[k]~=0 then
124    pl.line3( x, y, z )
125    else
126    pl.poin3( x, y, z, 1 )
127  end
128
129    pl.col0(3)
130    pl.mtex("t", 1.0, 0.5, 0.5, "#frPLplot Example 18 - Alt=" .. alt[k] .. ", Az=" .. az[k])
131end
132
133pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x19.lua
1
2    Illustrates backdrop plotting of world, US maps.
3    Contributed by Wesley Ebisuzaki.
4
5  Copyright (C) 2008 Werner Smekal
6
7  This file is part of PLplot.
8
9  PLplot is free software you can redistribute it and/or modify
10  it under the terms of the GNU General Library Public License as published
11  by the Free Software Foundation either version 2 of the License, or
12  (at your option) any later version.
13
14  PLplot is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Library General Public License for more details.
18
19  You should have received a copy of the GNU Library General Public License
20  along with PLplot if not, write to the Free Software
21  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
23dofile("plplot_examples.lua")
24
25
26function mapform19(n, x, y)
27  for i = 1, n do
28    radius = 90 - y[i]
29    xp = radius * math.cos(x[i] * math.pi / 180)
30    yp = radius * math.sin(x[i] * math.pi / 180)
31    x[i] = xp
32    y[i] = yp
33  end
34
35  return x, y
36end
37
38function normalize_longitude(lon)
39    if lon>=-180 and lon<=180 then
40        return lon;
41    else
42            times = math.floor((math.abs(lon)+180)/360)
43            if lon<0 then
44                return lon+360*times
45            else
46                return lon-360*times
47            end
48    end
49end
50
51function geolocation_labeler(axis, value)
52    if axis==pl.PL_Y_AXIS then
53        label_val = value
54        if label_val>0 then
55            direction_label = " N"
56        else
57            if label_val<0 then
58                direction_label = " S"
59            else
60                direction_label = "Eq"
61            end
62        end
63    else
64        if axis==pl.PL_X_AXIS then
65            label_val = normalize_longitude(value);
66            if label_val>0 then
67                direction_label = " E"
68            else
69                if label_val<0 then
70                    direction_label = " W"
71                else
72                    direction_label = ""
73                end
74            end
75        end
76    end
77
78    if axis==pl.PL_Y_AXIS and value==0 then
79        -- A special case for the equator
80        label = direction_label
81    else
82        label = math.abs(label_val) .. direction_label
83    end
84
85    return label
86end
87
88
89
90pl.parseopts(arg, pl.PL_PARSE_FULL)
91
92
93miny = -70
94maxy = 80
95
96pl.init()
97
98
99minx = 190
100maxx = 190+360
101
102pl.slabelfunc("geolocation_labeler");
103
104pl.col0(1)
105pl.env(minx, maxx, miny, maxy, 1, 70)
106pl.map(nil, "usaglobe", minx, maxx, miny, maxy)
107
108
109minx = 190
110maxx = 340
111
112pl.col0(1)
113pl.env(minx, maxx, miny, maxy, 1, 70)
114pl.map(nil, "usaglobe", minx, maxx, miny, maxy)
115
116pl.slabelfunc(nil);
117
118
119minx = 0
120maxx = 360
121
122pl.env(-75., 75., -75., 75., 1, -1)
123pl.map("mapform19", "globe", minx, maxx, miny, maxy)
124
125pl.lsty(2)
126pl.meridians("mapform19", 10, 10, 0, 360, -10, 80)
127pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x20.lua
1
2    plimage demo
3
4dofile("plplot_examples.lua")
5
6XDIM = 260
7YDIM = 220
8
9dbg = 0
10nosombrero = 0
11nointeractive = 0
12f_name=""
13
14
15function mypltr(x, y)
16  local x0 = (stretch["xmin"] + stretch["xmax"])*0.5
17  local y0 = (stretch["ymin"] + stretch["ymax"])*0.5
18  local dy = (stretch["ymax"]-stretch["ymin"])*0.5
19  local tx = x0 + (x0-x)*(1 - stretch["stretch"]*math.cos((y-y0)/dy*math.pi*0.5))
20  local ty = y
21
22  return tx, ty
23end
24
25
26function read_img(fname)
27  -- naive grayscale binary ppm reading. If you know how to, improve it
28  local fp = io.open(fname, "rb")
29  if fp==nil then
30    return 1
31  end
32
33  -- version
34  local ver = fp:read("*line")
35
36  if ver~="P5" then -- I only understand this!
37    fp:close()
38    return 1
39  end
40
41  while fp:read(1)=="#" do
42    local com = fp:read("*line")
43    if com==nil then
44      fp:close()
45      return 1
46    end
47  end
48  fp:seek("cur", -1)
49
50  local w, h, num_col = fp:read("*number", "*number", "*number")
51  if w==nil or h==nil or num_col==nil then -- width, height, num colors
52    fp:close()
53    return 1
54  end
55
56  -- read the rest of the line (only EOL)
57  fp:read("*line")
58
59  local img = fp:read(w*h)
60  fp:close()
61  if string.len(img)~=(w*h) then
62    return 1
63  end
64
65  local imf = {}
66
67  for i = 1, w do
68    imf[i] = {}
69    for j = 1, h do
70      imf[i][j] = string.byte(img, (h-j)*w+i) -- flip image up-down
71    end
72  end
73
74  return 0, imf, w, h, num_col
75end
76
77
78function save_plot(fname)
79  local cur_strm = pl.gstrm() -- get current stream
80  local new_strm = pl.mkstrm() -- create a new one
81
82  pl.sdev("psc") -- new device type. Use a known existing driver
83  pl.sfnam(fname) -- file name
84
85  pl.cpstrm(cur_strm, 0) -- copy old stream parameters to new stream
86  pl.replot() -- do the save
87  pl.end1() -- close new device
88
89  pl.sstrm(cur_strm) -- and return to previous one
90end
91
92
93function get_clip(xi, xe, yi, ye)
94  return 0, xi, xe, yi, ye
95end
96
97
98function gray_cmap(num_col)
99  local r = { 0, 1 }
100  local g = { 0, 1 }
101  local b = { 0, 1 }
102  local pos = { 0, 1 }
103
104  pl.scmap1n(num_col)
105  pl.scmap1l(1, pos, r, g, b)
106end
107
108
109x = {}
110y = {}
111z = {}
112r = {}
113img_f = {}
114cgrid2 = {}
115
116
117
118  --making a new selection the old one will re-appear.
119
120
121pl.parseopts(arg, pl.PL_PARSE_FULL)
122
123pl.init()
124
125z={}
126
127if dbg~=0 then
128  pl.env(1, XDIM, 1, YDIM, 1, 1) -- no plot box
129
130  -- build a one pixel square border, for diagnostics
131  for i = 1, XDIM do
132    z[i] = {}
133    z[i][1] = 1 -- left
134    z[i][YDIM] = 1 -- right
135  end
136
137  for i = 1, YDIM do
138    z[1][i] = 1 -- top
139    z[XDIM][i] = 1 -- botton
140  end
141
142  pl.lab("...around a blue square."," ","A red border should appear...")
143
144  pl.image(z, 1, XDIM, 1, YDIM, 0, 0, 1, XDIM, 1, YDIM)
145end
146
147if nosombrero==0 then
148  r = {}
149  pl.col0(2) -- draw a yellow plot box, useful for diagnostics! :(
150  pl.env(0, 2*math.pi, 0, 3*math.pi, 1, -1)
151
152  for i = 1, XDIM do
153    x[i] = (i-1)*2*math.pi/(XDIM-1)
154  end
155  for i = 1, YDIM do
156    y[i] = (i-1)*3*math.pi/(YDIM-1)
157  end
158
159  for i = 1, XDIM do
160    r[i] = {}
161    z[i] = {}
162    for j=1, YDIM do
163      r[i][j] = math.sqrt(x[i]^2+y[j]^2)+1e-3
164      z[i][j] = math.sin(r[i][j])/r[i][j]
165    end
166  end
167
168  pl.lab("No, an amplitude clipped \"sombrero\"", "", "Saturn?")
169  pl.ptex(2, 2, 3, 4, 0, "Transparent image")
170  pl.image(z, 0, 2*math.pi, 0, 3*math.pi, 0.05, 1, 0, 2*math.pi, 0, 3*math.pi)
171
172  -- save the plot
173  if f_name~="" then
174    save_plot(f_name)
175  end
176end
177
178status, img_f, width, height, num_col = read_img("lena.pgm")
179if status~=0 then
180  status, img_f, width, height, num_col = read_img("../lena.pgm")
181  if status~=0 then
182    pl.abort("No such file")
183    pl.plend()
184    os.exit()
185  end
186end
187
188gray_cmap(num_col)
189
190pl.env(1, width, 1, height, 1, -1)
191
192if nointeractive==0 then
193  pl.lab("Set and drag Button 1 to (re)set selection, Button 2 to finish."," ","Lena...")
194else
195  pl.lab(""," ","Lena...")
196end
197
198pl.image(img_f, 1, width, 1, height, 0, 0, 1, width, 1, height)
199
200if nointeractive==0 then
201  xi = 200
202  xe = 330
203  yi = 280
204  ye = 220
205
206  status, xi, xe, yi, ye = get_clip(xi, xe, yi, ye)
207  if status~=0 then -- get selection rectangle
208    pl.plend()
209    os.exit()
210  end
211
212  pl.spause(0)
213  pl.adv(0)
214
215  -- display selection only
216  pl.image(img_f, 1, width, 1, height, 0, 0, xi, xe, ye, yi)
217
218  pl.spause(1)
219
220  -- zoom in selection
221  pl.env(xi, xe, ye, yi, 1, -1)
222  pl.image(img_f, 1, width, 1, height, 0, 0, xi, xe, ye, yi)
223end
224
225img_max, img_min = pl.MinMax2dGrid(img_f)
226
227pl.col0(2)
228pl.env(0, width, 0, height, 1, -1)
229pl.lab("", "", "Reduced dynamic range image example")
230pl.imagefr(img_f, 0, width, 0, height, 0, 0, img_min + img_max*0.25, img_max - img_max*0.25)
231
232pl.env(0, width, 0, height, 1, -1)
233pl.lab("", "", "Distorted image example")
234
235stretch = {}
236stretch["xmin"] = 0
237stretch["xmax"] = width
238stretch["ymin"] = 0
239stretch["ymax"] = height
240stretch["stretch"] = 0.5
241
242
243cgrid2 = {}
244cgrid2["xg"] = {}
245cgrid2["yg"] = {}
246cgrid2["nx"] = width+1
247cgrid2["ny"] = height+1
248
249for i = 1, width+1 do
250  cgrid2["xg"][i] = {}
251  cgrid2["yg"][i] = {}
252  for j = 1, height+1 do
253    xx, yy = mypltr(i, j)
254    cgrid2["xg"][i][j] = xx
255    cgrid2["yg"][i][j] = yy
256  end
257end
258
259pl.imagefr(img_f, 0, width, 0, height, 0, 0, img_min, img_max, "mypltr")
260
261pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x21.lua
1    Grid data demo
2
3   Copyright (C) 200 Werner Smekal
4
5   This file is part of PLplot.
6
7   PLplot is free software you can redistribute it and/or modify
8   it under the terms of the GNU General Library Public License as published
9   by the Free Software Foundation either version 2 of the License, or
10   (at your option) any later version.
11
12   PLplot is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15   GNU Library General Public License for more details.
16
17   You should have received a copy of the GNU Library General Public License
18   along with PLplot if not, write to the Free Software
19   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
21
22dofile("plplot_examples.lua")
23
24
25function bit(x,b)
26    return (math.mod(x, 2^b) - math.mod(x,2^(b-1)) > 0)
27end
28
29function lor(x,y)
30    result = 0
31    for p=1,8 do result = result + (((bit(x,p) or bit(y,p)) == true) and 2^(p-1) or 0) end
32    return result
33end
34
35pts = 500
36xp = 25
37yp = 20
38nl = 16
39knn_order = 20
40threshold = 1.001
41wmin = -1e3
42randn = 0
43rosen = 0
44
45
46function cmap1_init()
47  i = { 0, 1 } -- left and right boundary
48
49  h = { 240, 0 } -- blue -> green -> yellow -> red
50  l = { 0.6, 0.6 }
51  s = { 0.8, 0.8 }
52
53  pl.scmap1n(256)
54  pl.scmap1l(0, i, h, l, s)
55end
56
57
58function create_grid(px, py)
59  local x = {}
60  local y = {}
61
62  for i = 1, px do
63    x[i] = xm + (xM-xm)*(i-1)/(px-1)
64  end
65
66  for i = 1, py do
67    y[i] = ym + (yM-ym)*(i-1)/(py-1)
68  end
69
70  return x, y
71end
72
73
74function create_data(pts)
75  local x = {}
76  local y = {}
77  local z = {}
78
79  for i = 1, pts do
80    xt = (xM-xm)*pl.randd()
81    yt = (yM-ym)*pl.randd()
82    if randn==0 then
83      x[i] = xt + xm
84      y[i] = yt + ym
85    else -- std=1, meaning that many points are outside the plot range
86      x[i] = math.sqrt(-2*math.log(xt)) * math.cos(2*math.pi*yt) + xm
87      y[i] = math.sqrt(-2*math.log(xt)) * math.sin(2*math.pi*yt) + ym
88    end
89    if rosen==0 then
90      r = math.sqrt(x[i]^2 + y[i]^2)
91      z[i] = math.exp(-r^2) * math.cos(2*math.pi*r)
92    else
93      z[i] = math.log((1-x[i])^2 + 100*(y[i] - x[i]^2)^2)
94    end
95  end
96
97  return x, y, z
98end
99
100
101title = { "Cubic Spline Approximation",
102          "Delaunay Linear Interpolation",
103          "Natural Neighbors Interpolation",
104          "KNN Inv. Distance Weighted",
105          "3NN Linear Interpolation",
106          "4NN Around Inv. Dist. Weighted" }
107
108
109
110xm = -0.2
111ym = -0.2
112xM = 0.6
113yM = 0.6
114
115pl.parseopts(arg, pl.PL_PARSE_FULL)
116
117opt = { 0, 0, wmin, knn_order, threshold, 0 }
118
119pl.init()
120
121pl.seed(5489)
122
123x, y, z = create_data(pts) -- the sampled data
124zmin = z[1]
125zmax = z[1]
126for i=2, pts do
127  if z[i]>zmax then zmax = z[i] end
128  if z[i]<zmin then zmin = z[i] end
129end
130
131xg, yg = create_grid(xp, yp) -- grid the data at
132clev = {}
133
134pl.col0(1)
135pl.env(xm, xM, ym, yM, 2, 0)
136pl.col0(15)
137pl.lab("X", "Y", "The original data sampling")
138pl.col0(2)
139pl.poin(x, y, 5)
140pl.adv(0)
141
142pl.ssub(3, 2)
143
144for k = 1, 2 do
145  pl.adv(0)
146  for alg=1, 6 do
147    zg = pl.griddata(x, y, z, xg, yg, alg, opt[alg])
148
149    --[[
150       - CSA can generate NaNs (only interpolates?!).
151       - DTLI and NNI can generate NaNs for points outside the convex hull
152         of the data points.
153       - NNLI can generate NaNs if a sufficiently thick triangle is not found
154
155       PLplot should be NaN/Inf aware, but changing it now is quite a job...
156       so, instead of not plotting the NaN regions, a weighted average over
157       the neighbors is done. --]]
158
159
160    if alg==pl.GRID_CSA or alg==pl.GRID_DTLI or alg==pl.GRID_NNLI or alg==pl.GRID_NNI then
161      for i = 1, xp do
162        for j = 1, yp do
163          if zg[i][j]~=zg[i][j] then -- average (IDW) over the 8 neighbors
164            zg[i][j] = 0
165            dist = 0
166
167            for ii=i-1, i+1 do
168              if ii<=xp then
169                for jj=j-1, j+1 do
170                  if jj<=yp then
171                    if ii>=1 and jj>=1 and zg[ii][jj]==zg[ii][jj] then
172                      if (math.abs(ii-i) + math.abs(jj-j)) == 1 then
173                        d = 1
174                      else
175                        d = 1.4142
176                      end
177                      zg[i][j] = zg[i][j] + zg[ii][jj]/(d^2)
178                      dist = dist + d
179                    end
180                  end
181                end
182              end
183            end
184            if dist~=0 then
185              zg[i][j] = zg[i][j]/dist
186            else
187              zg[i][j] = zmin
188            end
189          end
190        end
191      end
192    end
193
194    lzM, lzm = pl.MinMax2dGrid(zg)
195
196    if lzm~=lzm then lzm=zmin else lzm = math.min(lzm, zmin) end
197    if lzM~=lzM then lzM=zmax else lzM = math.max(lzM, zmax) end
198
199    -- Increase limits slightly to prevent spurious contours
200    -- due to rounding errors
201    lzm = lzm-0.01
202    lzM = lzM+0.01
203
204    pl.col0(1)
205
206    pl.adv(alg)
207
208    if k==1 then
209      for i = 1, nl do
210        clev[i] = lzm + (lzM-lzm)/(nl-1)*(i-1)
211      end
212
213      pl.env0(xm, xM, ym, yM, 2, 0)
214      pl.col0(15)
215      pl.lab("X", "Y", title[alg])
216      pl.shades(zg, xm, xM, ym, yM, clev, 1, 0, 1, 1)
217      pl.col0(2)
218    else
219      for i = 1, nl do
220        clev[i] = lzm + (lzM-lzm)/(nl-1)*(i-1)
221      end
222
223      cmap1_init()
224      pl.vpor(0, 1, 0, 0.9)
225      pl.wind(-1.1, 0.75, -0.65, 1.20)
226
227      -- For the comparison to be fair, all plots should have the
228      -- same z values, but to get the max/min of the data generated
229      -- by all algorithms would imply two passes. Keep it simple.
230      --
231      -- pl.w3d(1, 1, 1, xm, xM, ym, yM, zmin, zmax, 30, -60)
232
233
234      pl.w3d(1, 1, 1, xm, xM, ym, yM, lzm, lzM, 30, -40)
235      pl.box3("bntu", "X", 0, 0,
236              "bntu", "Y", 0, 0,
237              "bcdfntu", "Z", 0.5, 0)
238      pl.col0(15)
239      pl.lab("", "", title[alg])
240      pl.plot3dc(xg, yg, zg, lor(lor(pl.DRAW_LINEXY, pl.MAG_COLOR), pl.BASE_CONT), clev)
241    end
242  end
243end
244
245pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x22.lua
1
2    Simple vector plot example
3
4  Copyright (C) 2008 Werner Smekal
5
6  This file is part of PLplot.
7
8  PLplot is free software you can redistribute it and/or modify
9  it under the terms of the GNU General Library Public License as published
10  by the Free Software Foundation either version 2 of the License, or
11  (at your option) any later version.
12
13  PLplot is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Library General Public License for more details.
17
18  You should have received a copy of the GNU Library General Public License
19  along with PLplot if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22dofile("plplot_examples.lua")
23
24arrow_x = { -0.5, 0.5, 0.3, 0.5, 0.3, 0.5 }
25arrow_y = { 0, 0, 0.2, 0, -0.2, 0 }
26arrow2_x = { -0.5, 0.3, 0.3, 0.5, 0.3, 0.3 }
27arrow2_y = { 0, 0, 0.2, 0, -0.2, 0 }
28
29
30function circulation()
31    nx = 20
32    ny = 20
33    dx = 1
34    dy = 1
35
36    xmin = -nx/2*dx
37    xmax = nx/2*dx
38    ymin = -ny/2*dy
39    ymax = ny/2*dy
40
41  cgrid2 = {}
42    cgrid2["xg"] = {}
43    cgrid2["yg"] = {}
44    cgrid2["nx"] = nx
45    cgrid2["ny"] = ny
46    u = {}
47    v = {}
48
49    -- Create data - circulation around the origin.
50    for i = 1, nx do
51        x = (i-1-nx/2+0.5)*dx
52        cgrid2["xg"][i] = {}
53        cgrid2["yg"][i] = {}
54        u[i] = {}
55        v[i] = {}
56        for j=1, ny do
57            y = (j-1-ny/2+0.5)*dy
58            cgrid2["xg"][i][j] = x
59            cgrid2["yg"][i][j] = y
60            u[i][j] = y
61            v[i][j] = -x
62        end
63    end
64
65    -- Plot vectors with default arrows
66    pl.env(xmin, xmax, ymin, ymax, 0, 0)
67    pl.lab("(x)", "(y)", "#frPLplot Example 22 - circulation")
68    pl.col0(2)
69    pl.vect(u, v, 0, "pltr2", cgrid2 )
70    pl.col0(1)
71end
72
73
74function constriction()
75    nx = 20
76    ny = 20
77    dx = 1
78    dy = 1
79
80    xmin = -nx/2*dx
81    xmax = nx/2*dx
82    ymin = -ny/2*dy
83    ymax = ny/2*dy
84
85  cgrid2 = {}
86    cgrid2["xg"] = {}
87    cgrid2["yg"] = {}
88    cgrid2["nx"] = nx
89    cgrid2["ny"] = ny
90    u = {}
91    v = {}
92
93    Q = 2
94    for i = 1, nx do
95        x = (i-1-nx/2+0.5)*dx
96        cgrid2["xg"][i] = {}
97        cgrid2["yg"][i] = {}
98        u[i] = {}
99        v[i] = {}
100        for j = 1, ny do
101            y = (j-1-ny/2+0.5)*dy
102        cgrid2["xg"][i][j] = x
103        cgrid2["yg"][i][j] = y
104        b = ymax/4*(3-math.cos(math.pi*x/xmax))
105            if math.abs(y)<b then
106                dbdx = ymax/4*math.sin(math.pi*x/xmax)*y/b
107                u[i][j] = Q*ymax/b
108                v[i][j] = dbdx*u[i][j]
109            else
110                u[i][j] = 0
111                v[i][j] = 0
112            end
113        end
114    end
115
116    pl.env(xmin, xmax, ymin, ymax, 0, 0)
117    pl.lab("(x)", "(y)", "#frPLplot Example 22 - constriction")
118    pl.col0(2)
119    pl.vect(u, v, -0.5, "pltr2", cgrid2)
120    pl.col0(1)
121end
122
123
124function f2mnmx(f, nx, ny)
125    fmax = f[1][1]
126    fmin = fmax
127
128    for i=1, nx do
129        for j=1, ny do
130        fmax = math.max(fmax, f[i][j])
131        fmin = math.min(fmin, f[i][j])
132        end
133    end
134
135    return fmin, fmax
136end
137
138function potential()
139  nper = 100
140  nlevel = 10
141  nr = 20
142  ntheta = 20
143
144  u = {}
145  v = {}
146  z = {}
147  clevel = {}
148  px = {}
149  py = {}
150
151  cgrid2 = {}
152  cgrid2["xg"] = {}
153  cgrid2["yg"] = {}
154  cgrid2["nx"] = nr
155  cgrid2["ny"] = ntheta
156
157  -- Potential inside a conducting cylinder (or sphere) by method of images.
158  -- Charge 1 is placed at (d1, d1), with image charge at (d2, d2).
159  -- Charge 2 is placed at (d1, -d1), with image charge at (d2, -d2).
160  -- Also put in smoothing term at small distances.
161  rmax = nr
162
163  eps = 2
164
165  q1 = 1
166  d1 = rmax/4
167
168  q1i = -q1*rmax/d1
169  d1i = rmax^2/d1
170
171  q2 = -1
172  d2 = rmax/4
173
174  q2i = -q2*rmax/d2
175  d2i = rmax^2/d2
176
177  for i = 1, nr do
178      r = i - 0.5
179    cgrid2["xg"][i] = {}
180    cgrid2["yg"][i] = {}
181    u[i] = {}
182    v[i] = {}
183    z[i] = {}
184      for j = 1, ntheta do
185        theta = 2*math.pi/(ntheta-1)*(j-0.5)
186        x = r*math.cos(theta)
187        y = r*math.sin(theta)
188        cgrid2["xg"][i][j] = x
189        cgrid2["yg"][i][j] = y
190        div1 = math.sqrt((x-d1)^2 + (y-d1)^2 + eps^2)
191        div1i = math.sqrt((x-d1i)^2 + (y-d1i)^2 + eps^2)
192        div2 = math.sqrt((x-d2)^2 + (y+d2)^2 + eps^2)
193        div2i = math.sqrt((x-d2i)^2 + (y+d2i)^2 + eps^2)
194        z[i][j] = q1/div1 + q1i/div1i + q2/div2 + q2i/div2i
195        u[i][j] = -q1*(x-d1)/div1^3 - q1i*(x-d1i)/div1i^3
196                    -q2*(x-d2)/div2^3 - q2i*(x-d2i)/div2i^3
197        v[i][j] = -q1*(y-d1)/div1^3 - q1i*(y-d1i)/div1i^3
198                    -q2*(y+d2)/div2^3 - q2i*(y+d2i)/div2i^3
199      end
200  end
201
202  xmin, xmax = f2mnmx(cgrid2["xg"], nr, ntheta)
203  ymin, ymax = f2mnmx(cgrid2["yg"], nr, ntheta)
204  zmin, zmax = f2mnmx(z, nr, ntheta)
205
206  pl.env(xmin, xmax, ymin, ymax, 0, 0)
207  pl.lab("(x)", "(y)", "#frPLplot Example 22 - potential gradient vector plot")
208
209  -- Plot contours of the potential
210  dz = (zmax-zmin)/nlevel
211  for i = 1, nlevel do
212      clevel[i] = zmin + (i-0.5)*dz
213  end
214
215  pl.col0(3)
216  pl.lsty(2)
217  pl.cont(z, 1, nr, 1, ntheta, clevel, "pltr2", cgrid2)
218  pl.lsty(1)
219  pl.col0(1)
220
221  -- Plot the vectors of the gradient of the potential
222  pl.col0(2)
223  pl.vect(u, v, 25, "pltr2", cgrid2)
224  pl.col0(1)
225
226  -- Plot the perimeter of the cylinder
227  for i=1, nper do
228    theta = 2*math.pi/(nper-1)*(i-1)
229    px[i] = rmax*math.cos(theta)
230    py[i] = rmax*math.sin(theta)
231  end
232
233  pl.line(px, py)
234end
235
236
237
238pl.parseopts(arg, pl.PL_PARSE_FULL)
239
240pl.init()
241
242circulation()
243
244fill = 0
245
246pl.svect(arrow_x, arrow_y, fill)
247constriction()
248
249fill = 1
250pl.svect(arrow2_x, arrow2_y, fill)
251constriction()
252
253potential()
254
255pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x23.lua
1
2    Displays Greek letters and mathematically interesting Unicode ranges
3
4    Copyright (C) 2009 Werner Smekal
5
6    This file is part of PLplot.
7
8    PLplot is free software you can redistribute it and/or modify
9    it under the terms of the GNU General Library Public License as published
10    by the Free Software Foundation either version 2 of the License, or
11    (at your option) any later version.
12
13    PLplot is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16    GNU Library General Public License for more details.
17
18    You should have received a copy of the GNU Library General Public License
19    along with PLplot if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22dofile("plplot_examples.lua")
23
24
25Greek = {
26  "#gA","#gB","#gG","#gD","#gE","#gZ","#gY","#gH","#gI","#gK","#gL","#gM",
27  "#gN","#gC","#gO","#gP","#gR","#gS","#gT","#gU","#gF","#gX","#gQ","#gW",
28  "#ga","#gb","#gg","#gd","#ge","#gz","#gy","#gh","#gi","#gk","#gl","#gm",
29  "#gn","#gc","#go","#gp","#gr","#gs","#gt","#gu","#gf","#gx","#gq","#gw"
30}
31
32Type1 = {
33  32, 33, 35, 37, 38,
34  40, 41, 43, 44, 46,
35  47, 48, 49, 50, 51,
36  52, 53, 54, 55, 56,
37  57, 58, 59, 60, 61,
38  62, 63, 91, 93, 95,
39  123, 124, 125, 169, 172,
40  174, 176, 177, 215, 247,
41  402, 913, 914, 915, 916,
42  917, 918, 919, 920, 921,
43  922, 923, 924, 925, 926,
44  927, 928, 929, 931, 932,
45  933, 934, 935, 936, 937,
46  945, 946, 947, 948, 949,
47  950, 951, 952, 953, 954,
48  955, 956, 957, 958, 959,
49  960, 961, 962, 963, 964,
50  965, 966, 967, 968, 969,
51  977, 978, 981, 982, 8226,
52  8230, 8242, 8243, 8254, 8260,
53  8465, 8472, 8476, 8482, 8486,
54  8501, 8592, 8593, 8594, 8595,
55  8596, 8629, 8656, 8657, 8658,
56  8659, 8660, 8704, 8706, 8707,
57  8709, 8710, 8711, 8712, 8713,
58  8715, 8719, 8721, 8722, 8725,
59  8727, 8730, 8733, 8734, 8736,
60  8743, 8744, 8745, 8746, 8747,
61  8756, 8764, 8773, 8776, 8800,
62  8801, 8804, 8805, 8834, 8835,
63  8836, 8838, 8839, 8853, 8855,
64  8869, 8901, 8992, 8993, 9001,
65  9002, 9674, 9824, 9827, 9829,
66  9830
67}
68
69title = {
70  "#<0x10>PLplot Example 23 - Greek Letters",
71  "#<0x10>PLplot Example 23 - Type 1 Symbol Font Glyphs by Unicode (a)",
72  "#<0x10>PLplot Example 23 - Type 1 Symbol Font Glyphs by Unicode (b)",
73  "#<0x10>PLplot Example 23 - Type 1 Symbol Font Glyphs by Unicode (c)",
74  "#<0x10>PLplot Example 23 - Number Forms Unicode Block",
75  "#<0x10>PLplot Example 23 - Arrows Unicode Block (a)",
76  "#<0x10>PLplot Example 23 - Arrows Unicode Block (b)",
77  "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (a)",
78  "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (b)",
79  "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (c)",
80  "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (d)"
81}
82
83lo = {
84  0,
85  0,
86  64,
87  128,
88  8531,
89  8592,
90  8656,
91  8704,
92  8768,
93  8832,
94  8896
95}
96
97hi = {
98  48,
99  64,
100  128,
101  166,
102  8580,
103  8656,
104  8704,
105  8768,
106  8832,
107  8896,
108  8960
109}
110
111nxcells = {
112  12,
113  8,
114  8,
115  8,
116  8,
117  8,
118  8,
119  8,
120  8,
121  8,
122  8
123}
124
125nycells = {
126  8,
127  8,
128  8,
129  8,
130  8,
131  8,
132  8,
133  8,
134  8,
135  8,
136  8
137}
138
139offset = {
140  0,
141  0,
142  64,
143  128,
144  0,
145  0,
146  0,
147  0,
148  0,
149  0,
150  0
151}
152
153FCI_COMBINATIONS = 30
154fci = {
155  2147483648,
156  2147483649,
157  2147483650,
158  2147483651,
159  2147483652,
160  2147483664,
161  2147483665,
162  2147483666,
163  2147483667,
164  2147483668,
165  2147483680,
166  2147483681,
167  2147483682,
168  2147483683,
169  2147483684,
170  2147483904,
171  2147483905,
172  2147483906,
173  2147483907,
174  2147483908,
175  2147483920,
176  2147483921,
177  2147483922,
178  2147483923,
179  2147483924,
180  2147483936,
181  2147483937,
182  2147483938,
183  2147483939,
184  2147483940
185}
186
187family = {
188  "sans-serif",
189  "serif",
190  "monospace",
191  "script",
192  "symbol"
193}
194
195style = {
196  "upright",
197  "italic",
198  "oblique"
199}
200
201weight = {
202  "medium",
203  "bold"
204}
205
206pl.parseopts(arg, pl.PL_PARSE_FULL)
207
208pl.init()
209
210for page=1, 11 do
211  pl.adv(0)
212
213  -- Set up viewport and window
214  pl.vpor(0.02, 0.98, 0.02, 0.90)
215  pl.wind(0, 1, 0, 1)
216  xmin, xmax, ymin, ymax = pl.gspa()
217  pl.schr(0, 0.8)
218  ycharacter_scale = (1-0)/(ymax-ymin)
219
220  -- Factor should be 0.5, but heuristically it turns out to be larger.
221  chardef, charht = pl.gchr()
222  yoffset = charht*ycharacter_scale
223
224  -- Draw the grid using plbox
225  pl.col0(2)
226  deltax = 1.0/nxcells[page]
227  deltay = 1.0/nycells[page]
228  pl.box("bcg", deltax, 0, "bcg", deltay, 0)
229  pl.col0(15)
230  length=hi[page]-lo[page]
231  slice = 1
232
233  for j=nycells[page]-1, -1, -1 do
234    y = (0.5+j)*deltay
235    for i=1, nxcells[page] do
236      x = (i-0.5)*deltax
237      if slice<=length then
238        if page==1 then
239          cmdString = "#" .. Greek[slice]
240        elseif (page>=2) and (page<=4) then
241          cmdString = string.format("##[0x%.4x]", Type1[offset[page]+slice])
242        elseif page>4 then
243          cmdString = string.format("##[0x%.4x]", lo[page]+slice-1)
244        end
245        pl.ptex(x, y+yoffset, 1, 0, 0.5, string.sub(cmdString,2))
246        pl.ptex(x, y-yoffset, 1, 0, 0.5, cmdString)
247      end
248      slice = slice + 1
249    end
250  end
251
252  pl.schr(0, 1)
253
254  -- Page title
255  pl.mtex("t", 1.5, 0.5, 0.5, title[page])
256end
257
258fci_old = pl.gfci()
259ifamily, istyle, iweight = pl.gfont()
260print(string.format("For example 23 prior to page 12 the FCI is 0x%x", fci_old))
261print(string.format("For example 23 prior to page 12 the font family, style and weight are %s %s %s",
262                    family[ifamily+1], style[istyle+1], weight[iweight+1]))
263
264for page=12, 16 do
265  dy = 0.030
266
267  pl.adv(0)
268  pl.vpor(0.02, 0.98, 0.02, 0.90)
269  pl.wind(0, 1, 0, 1)
270  pl.sfci(0)
271
272  if page==12 then
273    pl.mtex("t", 1.5, 0.5, 0.5, "#<0x10>PLplot Example 23 - Set Font with plsfci")
274  elseif page==13 then
275    pl.mtex("t", 1.5, 0.5, 0.5, "#<0x10>PLplot Example 23 - Set Font with plsfont")
276  elseif page==14 then
277    pl.mtex("t", 1.5, 0.5, 0.5, "#<0x10>PLplot Example 23 - Set Font with ##<0x8nnnnnnn> construct")
278  elseif page==15 then
279    pl.mtex("t", 1.5, 0.5, 0.5, "#<0x10>PLplot Example 23 - Set Font with ##<0xmn> constructs")
280  elseif page==16 then
281    pl.mtex("t", 1.5, 0.5, 0.5, "#<0x10>PLplot Example 23 - Set Font with ##<FCI COMMAND STRING/> constructs")
282  end
283
284  pl.schr(0, 0.75)
285  for i=1, FCI_COMBINATIONS do
286    family_index = math.mod(i-1, 5)+1
287    style_index = math.mod(math.floor((i-1)/5), 3)+1
288    weight_index = math.mod(math.floor((i-1)/5/3), 2)+1
289    if page==12 then
290      pl.sfci(fci[i])
291      str = string.format("Page 12, %s, %s, %s: The quick brown fox jumps over the lazy dog",
292                          family[family_index], style[style_index], weight[weight_index])
293    elseif page==13 then
294      pl.sfont(family_index-1, style_index-1, weight_index-1)
295      str = string.format("Page 13, %s, %s, %s: The quick brown fox jumps over the lazy dog",
296                          family[family_index], style[style_index], weight[weight_index])
297    elseif page==14 then
298      str = string.format("Page 14, %s, %s, %s: #<0x%x>The quick brown fox jumps over the lazy dog",
299                          family[family_index], style[style_index], weight[weight_index], fci[i])
300    elseif page==15 then
301      str = string.format("Page 15, %s, %s, %s: #<0x%1x0>#<0x%1x1>#<0x%1x2>The quick brown fox jumps over the lazy dog",
302                          family[family_index], style[style_index], weight[weight_index],
303                          family_index-1, style_index-1, weight_index-1)
304    elseif page==16 then
305      str = string.format("Page 16, %s, %s, %s: #<%s/>#<%s/>#<%s/>The quick brown fox jumps over the lazy dog",
306                          family[family_index], style[style_index], weight[weight_index],
307                          family[family_index], style[style_index], weight[weight_index])
308    end
309    pl.ptex(0, 1-(i-0.5)*dy, 1, 0, 0, str)
310  end
311
312  pl.schr(0, 1)
313end
314
315pl.col0(1)
316
317pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x24.lua
1
2    Unicode Pace Flag
3
4  Copyright (C) 2008 Werner Smekal
5
6  This file is part of PLplot.
7
8  PLplot is free software you can redistribute it and/or modify
9  it under the terms of the GNU General Library Public License as published
10  by the Free Software Foundation either version 2 of the License, or
11  (at your option) any later version.
12
13  PLplot is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Library General Public License for more details.
17
18  You should have received a copy of the GNU Library General Public License
19  along with PLplot if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22   In Debian, run like this:
23
24   ( TTFDIR=/usr/share/fonts/truetype \
25     PLPLOT_FREETYPE_SANS_FONT=$TTFDIR/arphic/bkai00mp.ttf \
26     PLPLOT_FREETYPE_SERIF_FONT=$TTFDIR/freefont/FreeSerif.ttf \
27     PLPLOT_FREETYPE_MONO_FONT=$TTFDIR/ttf-devanagari-fonts/lohit_hi.ttf \
28     PLPLOT_FREETYPE_SCRIPT_FONT=$TTFDIR/unfonts/UnBatang.ttf \
29     PLPLOT_FREETYPE_SYMBOL_FONT=$TTFDIR/ttf-bengali-fonts/JamrulNormal.ttf \
30     ./x24c -dev png -drvopt smooth=0 -o x24c.png )
31
32   Packages needed:
33
34   ttf-arphic-bkai00mp
35   ttf-freefont
36   ttf-devanagari-fonts
37   ttf-unfonts
38   ttf-bengali-fonts
39
40dofile("plplot_examples.lua")
41
42red = { 240, 204, 204, 204, 0, 39, 125 }
43green = { 240, 0, 125, 204, 204, 80, 0 }
44blue = { 240, 0, 0, 0, 0, 204, 125 }
45
46px = { 0, 0, 1, 1 }
47py = { 0, 0.25, 0.25, 0 }
48
49sx = {
50  0.16374,
51  0.15844,
52  0.15255,
53  0.17332,
54  0.50436,
55  0.51721,
56  0.49520,
57  0.48713,
58  0.83976,
59  0.81688,
60  0.82231,
61  0.82647
62}
63
64sy = {
65  0.125,
66  0.375,
67  0.625,
68  0.875,
69  0.125,
70  0.375,
71  0.625,
72  0.875,
73  0.125,
74  0.375,
75  0.625,
76  0.875
77}
78
79
80
81peace = {
82  -- Mandarin
83  "#<0x00>和平",
84  -- Hindi
85  "#<0x20>शांति",
86  -- English
87  "#<0x10>Peace",
88  -- Hebrew
89  "#<0x10>שלום",
90  -- Russian
91  "#<0x10>Мир",
92  -- German
93  "#<0x10>Friede",
94  -- Korean
95  "#<0x30>평화",
96  -- French
97  "#<0x10>Paix",
98  -- Spanish
99  "#<0x10>Paz",
100  -- Arabic
101  "#<0x10>ﺳﻼم",
102  -- Turkish
103  "#<0x10>Barış",
104  -- Kurdish
105  "#<0x10>Hasîtî",
106}
107
108pl.parseopts(arg, pl.PL_PARSE_FULL)
109
110pl.init()
111
112pl.adv(0)
113pl.vpor(0, 1, 0, 1)
114pl.wind(0, 1, 0, 1)
115pl.col0(0)
116pl.box("", 1, 0, "", 1, 0)
117
118pl.scmap0n(7)
119pl.scmap0(red, green, blue)
120
121pl.schr(0, 4)
122pl.font(1)
123
124for i = 1, 4 do
125  pl.col0(i)
126  pl.fill(px, py)
127
128  for j = 1, 4 do
129    py[j] = py[j] + 1/4
130  end
131end
132
133pl.col0(0)
134for i = 1, 12 do
135  pl.ptex(sx[i], sy[i], 1, 0, 0.5, peace[i])
136end
137
138pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x25.lua
1
2    Filling and clipping polygons.
3
4  Copyright (C) 2008 Werner Smekal
5
6  This file is part of PLplot.
7
8  PLplot is free software you can redistribute it and/or modify
9  it under the terms of the GNU General Library Public License as published
10  by the Free Software Foundation either version 2 of the License, or
11  (at your option) any later version.
12
13  PLplot is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Library General Public License for more details.
17
18  You should have received a copy of the GNU Library General Public License
19  along with PLplot if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22dofile("plplot_examples.lua")
23
24
25xextreme = {}
26yextreme ={}
27x0 = {}
28y0 = {}
29
30pl.parseopts(arg, pl.PL_PARSE_FULL)
31
32pl.ssub(3, 3)
33pl.init()
34
35xextreme = { { -120, 120 }, { -120, 120 }, { -120, 120 }, { -80, 80 }, { -220, -120 },
36             { -20, 20 }, { -20, 20 }, { -80, 80 }, { 20, 120 } }
37
38yextreme = { { -120, 120 }, { 20, 120 }, { -20, 120 }, { -20, 120 }, { -120, 120 },
39             { -120, 120 }, { -20, 20 }, { -80, 80 }, { -120, 120 } }
40
41for k = 1, 2 do
42for j = 1, 4 do
43  if j==1 then
44    -- Polygon 1: a diamond
45    x0 = { 0, -100, 0, 100 }
46    y0 = { -100, 0, 100, 0}
47  end
48  if j==2 then
49    -- Polygon 1: a diamond - reverse direction
50    x0 = { 100, 0, -100, 0 }
51    y0 = { 0, 100, 0, -100}
52  end
53  if j==3 then
54    -- Polygon 2: a square with punctures
55    x0 = { -100, -100, 80, -100, -100, -80, 0, 80, 100, 100 }
56    y0 = { -100, -80, 0, 80, 100, 100, 80, 100, 100, -100}
57  end
58  if j==4 then
59    -- Polygon 2: a square with punctures - reversed direction
60    x0 = { 100, 100, 80, 0, -80, -100, -100, 80, -100, -100 }
61    y0 = { -100, 100, 100, 80, 100, 100, 80, 0, -80, -100}
62  end
63
64  for i = 1, 9 do
65    pl.adv(0)
66    pl.vsta()
67    pl.wind(xextreme[i][1], xextreme[i][2], yextreme[i][1], yextreme[i][2])
68
69    pl.col0(2)
70    pl.box("bc", 1, 0, "bcnv", 10, 0)
71    pl.col0(1)
72    pl.psty(0)
73    if k==1 then
74      pl.fill(x0, y0)
75    else
76      pl.gradient(x0, y0, 45.)
77    end
78    pl.col0(2)
79    pl.lsty(1)
80    pl.line(x0, y0)
81  end
82end
83end
84
85pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x26.lua
1
2   $Id: x26.lua 9506 2009-02-11 08:23:29Z smekal $
3
4   Multi-lingual version of the first page of example 4.
5
6   Copyright (C) 2009 Werner Smekal
7
8   Thanks to the following for providing translated strings for this example:
9   Valery Pipin (Russian)
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  This example designed just for devices (e.g., psttfc and the
29  cairo-related devices) that use the pango and fontconfig libraries. The
30  best choice of glyph is selected by fontconfig and automatically rendered
31  by pango in way that is sensitive to complex text layout (CTL) language
32  issues for each unicode character in this example. Of course, you must
33  have the appropriate TrueType fonts installed to have access to all the
34  required glyphs.
35
36  Translation instructions: The strings to be translated are given by
37  x_label, y_label, alty_label, title_label, and line_label below. The
38  encoding used must be UTF-8.
39
40  The following strings to be translated involve some scientific/mathematical
41  jargon which is now discussed further to help translators.
42
43  (1) dB is a decibel unit, see http://en.wikipedia.org/wiki/Decibel .
44  (2) degrees is an angular measure, see
45      http://en.wikipedia.org/wiki/Degree_(angle) .
46  (3) low-pass filter is one that transmits (passes) low frequencies.
47  (4) pole is in the mathematical sense, see
48      http://en.wikipedia.org/wiki/Pole_(complex_analysis) . "Single Pole"
49      means a particular mathematical transformation of the filter function has
50      a single pole, see
51      http://ccrma.stanford.edu/~jos/filters/Pole_Zero_Analysis_I.html .
52      Furthermore, a single-pole filter must have an inverse square decline
53      (or -20 db/decade). Since the filter plotted here does have that
54      characteristic, it must by definition be a single-pole filter, see also
55      http://www-k.ext.ti.com/SRVS/Data/ti/KnowledgeBases/analog/document/faqs/1p.htm
56  (5) decade represents a factor of 10, see
57      http://en.wikipedia.org/wiki/Decade_(log_scale) .
58
59dofile("plplot_examples.lua")
60
61x_label = { "Frequency", "Частота" }
62y_label = { "Amplitude (dB)", "Амплитуда (dB)" }
63alty_label = { "Phase shift (degrees)", "Фазовый сдвиг (градусы)" }
64title_label = { "Single Pole Low-Pass Filter", "Однополюсный Низко-Частотный Фильтр" }
65line_label = { "-20 dB/decade", "-20 dB/десяток" }
66
67
68
69function plot1(typ, x_label, y_label, alty_label, title_label, line_label)
70  freql = {}
71  ampl = {}
72  phase = {}
73
74  pl.adv(0)
75
76  -- Set up data for log plot
77
78  f0 = 1
79  for i = 1, 101 do
80    freql[i] = -2 + (i-1)/20
81    freq = 10^freql[i]
82    ampl[i] = 20 * math.log10(1/math.sqrt(1+(freq/f0)^2))
83    phase[i] = -180/math.pi*math.atan(freq/f0)
84  end
85
86  pl.vpor(0.15, 0.85, 0.1, 0.9)
87  pl.wind(-2, 3, -80, 0)
88
89  -- Try different axis and labelling styles.
90  pl.col0(1)
91  if typ==0 then
92    pl.box("bclnst", 0, 0, "bnstv", 0, 0)
93  else
94    pl.box("bcfghlnst", 0, 0, "bcghnstv", 0, 0)
95  end
96
97  -- Plot ampl vs freq
98  pl.col0(2)
99  pl.line(freql, ampl)
100  pl.col0(1)
101  pl.ptex(1.6, -30, 1, -20, 0.5, line_label)
102
103  -- Put labels on
104  pl.col0(1)
105  pl.mtex("b", 3.2, 0.5, 0.5, x_label)
106  pl.mtex("t", 2, 0.5, 0.5, title_label)
107  pl.col0(2)
108  pl.mtex("l", 5, 0.5, 0.5, y_label)
109
110  -- For the gridless case, put phase vs freq on same plot
111  if typ==0 then
112    pl.col0(1)
113    pl.wind(-2, 3, -100, 0)
114    pl.box("", 0, 0, "cmstv", 30, 3)
115    pl.col0(3)
116    pl.line(freql, phase)
117    pl.col0(3)
118    pl.mtex("r", 5, 0.5, 0.5, alty_label)
119  end
120end
121
122
123
124pl.parseopts(arg, pl.PL_PARSE_FULL)
125
126pl.init()
127pl.font(2)
128
129for i = 1, 2 do
130  plot1(0, x_label[i], y_label[i], alty_label[i], title_label[i], line_label[i])
131end
132
133pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x27.lua
1
2    Drawing "spirograph" curves - epitrochoids, cycolids, roulettes
3
4   Copyright (C) 2009 Werner Smekal
5
6  This file is part of PLplot.
7
8  PLplot is free software you can redistribute it and/or modify
9  it under the terms of the GNU General Library Public License as published
10  by the Free Software Foundation either version 2 of the License, or
11  (at your option) any later version.
12
13  PLplot is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Library General Public License for more details.
17
18  You should have received a copy of the GNU Library General Public License
19  along with PLplot if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22dofile("plplot_examples.lua")
23
24
25function cycloid()
26  -- TODO
27end
28
29
30function spiro( params )
31  NPNT = 20000
32  xcoord = {}
33  ycoord = {}
34
35  -- Fill the coordinates
36  windings = params[4]
37  steps = math.floor(NPNT/windings)
38  dphi = 8*math.acos(-1)/steps
39
40  xmin = 0 -- This initialisation is safe!
41  xmax = 0
42  ymin = 0
43  ymax = 0
44
45  for i = 1, windings*steps+1 do
46    phi = (i-1) * dphi
47    phiw = (params[1]-params[2])/params[2]*phi
48    xcoord[i] = (params[1]-params[2])*math.cos(phi) + params[3]*math.cos(phiw)
49    ycoord[i] = (params[1]-params[2])*math.sin(phi) - params[3]*math.sin(phiw)
50
51    if xmin>xcoord[i] then xmin = xcoord[i] end
52    if xmax<xcoord[i] then xmax = xcoord[i] end
53    if ymin>ycoord[i] then ymin = ycoord[i] end
54    if ymax<ycoord[i] then ymax = ycoord[i] end
55  end
56
57  if (xmax-xmin)>(ymax-ymin) then
58    scale = xmax - xmin
59  else
60    scale = ymax - ymin
61  end
62  xmin = -0.65*scale
63  xmax = 0.65*scale
64  ymin = -0.65*scale
65  ymax = 0.65*scale
66
67  pl.wind(xmin, xmax, ymin, ymax)
68
69  pl.col0(1)
70  pl.line(xcoord, ycoord)
71end
72
73
74
75params = {
76  { 21, 7, 7, 3 }, -- Deltoid
77  { 21, 7, 10, 3 },
78  { 21, -7, 10, 3 },
79  { 20, 3, 7, 20 },
80  { 20, 3, 10, 20 },
81  { 20, -3, 10, 20 },
82  { 20, 13, 7, 20 },
83  { 20, 13, 20, 20 },
84  { 20,-13, 20, 20 } }
85
86
87pl.parseopts(arg, pl.PL_PARSE_FULL)
88
89pl.init()
90
91cycloid()
92
93
94pl.ssub(3, 3) -- Three by three window
95
96for i = 1, 9 do
97  pl.adv(0)
98  pl.vpor(0, 1, 0, 1)
99  spiro(params[i])
100end
101
102pl.adv(0)
103pl.ssub(1, 1) -- One window per curve
104
105for i = 1, 9 do
106  pl.adv(0)
107  pl.vpor(0, 1, 0, 1)
108  spiro(params[i])
109end
110
111pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x28.lua
1
2    pl.mtex3, plptex3 demo.
3
4   Copyright (C) 2009 Werner Smekal
5
6  This file is part of PLplot.
7
8  PLplot is free software you can redistribute it and/or modify
9  it under the terms of the GNU General Library Public License as published
10  by the Free Software Foundation either version 2 of the License, or
11  (at your option) any later version.
12
13  PLplot is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Library General Public License for more details.
17
18  You should have received a copy of the GNU Library General Public License
19  along with PLplot if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22
23dofile("plplot_examples.lua")
24
25XPTS = 2
26YPTS = 2
27NREVOLUTION = 16
28NROTATION = 8
29NSHEAR = 8
30
31
32xmin=0
33xmax=1
34xmid = 0.5*(xmax + xmin)
35xrange = xmax - xmin
36ymin=0
37ymax=1
38ymid = 0.5*(ymax + ymin)
39yrange = ymax - ymin
40zmin=0
41zmax=1
42zmid = 0.5*(zmax + zmin)
43zrange = zmax - zmin
44ysmin = ymin + 0.1 * yrange
45ysmax = ymax - 0.1 * yrange
46ysrange = ysmax - ysmin
47dysrot = ysrange / ( NROTATION - 1 )
48dysshear = ysrange / ( NSHEAR - 1 )
49zsmin = zmin + 0.1 * zrange
50zsmax = zmax - 0.1 * zrange
51zsrange = zsmax - zsmin
52dzsrot = zsrange / ( NROTATION - 1 )
53dzsshear = zsrange / ( NSHEAR - 1 )
54
55pstring = "The future of our civilization depends on software freedom."
56
57x = {}
58y = {}
59z = {}
60
61for i = 1, XPTS do
62  x[i] = xmin + (i-1) * (xmax-xmin)/(XPTS-1)
63end
64
65for j = 1, YPTS do
66 y[j] = ymin + (j-1) * (ymax-ymin)/(YPTS-1)
67end
68
69for i = 1, XPTS do
70  z[i] = {}
71  for j = 1, YPTS do
72    z[i][j] = 0
73  end
74end
75
76pl.parseopts(arg, pl.PL_PARSE_FULL)
77
78pl.init()
79
80pl.adv(0)
81pl.vpor(-0.15, 1.15, -0.05, 1.05)
82pl.wind(-1.2, 1.2, -0.8, 1.5)
83pl.w3d(1, 1, 1, xmin, xmax, ymin, ymax, zmin, zmax, 20, 45)
84
85pl.col0(2)
86pl.box3("b", "", xmax-xmin, 0,
87        "b", "", ymax-ymin, 0,
88        "bcd", "", zmax-zmin, 0)
89
90pl.schr(0, 1)
91for i = 1, NREVOLUTION do
92  omega = 2*math.pi*(i-1)/NREVOLUTION
93  sin_omega = math.sin(omega)
94  cos_omega = math.cos(omega)
95  x_inclination = 0.5*xrange*cos_omega
96  y_inclination = 0.5*yrange*sin_omega
97  z_inclination = 0
98  x_shear = -0.5*xrange*sin_omega
99  y_shear = 0.5*yrange*cos_omega
100  z_shear = 0
101  pl.ptex3( xmid, ymid, zmin, x_inclination, y_inclination, z_inclination,
102           x_shear, y_shear, z_shear, 0, " revolution")
103end
104
105pl.schr(0, 1)
106for i = 1, NREVOLUTION do
107  omega = 2.*math.pi*(i-1)/NREVOLUTION
108  sin_omega = math.sin(omega)
109  cos_omega = math.cos(omega)
110  x_inclination = 0.
111  y_inclination = -0.5*yrange*cos_omega
112  z_inclination = 0.5*zrange*sin_omega
113  x_shear = 0
114  y_shear = 0.5*yrange*sin_omega
115  z_shear = 0.5*zrange*cos_omega
116  pl.ptex3(xmax, ymid, zmid, x_inclination, y_inclination, z_inclination,
117           x_shear, y_shear, z_shear, 0, " revolution")
118end
119
120pl.schr(0, 1)
121for i = 1, NREVOLUTION do
122  omega = 2.*math.pi*(i-1)/NREVOLUTION
123  sin_omega = math.sin(omega)
124  cos_omega = math.cos(omega)
125  x_inclination = 0.5*xrange*cos_omega
126  y_inclination = 0.
127  z_inclination = 0.5*zrange*sin_omega
128  x_shear = -0.5*xrange*sin_omega
129  y_shear = 0.
130  z_shear = 0.5*zrange*cos_omega
131  pl.ptex3(xmid, ymax, zmid, x_inclination, y_inclination, z_inclination,
132           x_shear, y_shear, z_shear, 0, " revolution")
133end
134
135pl.mesh(x, y, z, pl.DRAW_LINEXY)
136
137pl.adv(0)
138pl.vpor(-0.15, 1.15, -0.05, 1.05)
139pl.wind(-1.2, 1.2, -0.8, 1.5)
140pl.w3d(1, 1, 1, xmin, xmax, ymin, ymax, zmin, zmax, 20, 45)
141
142pl.col0(2)
143pl.box3("b", "", xmax-xmin, 0,
144        "b", "", ymax-ymin, 0,
145        "bcd", "", zmax-zmin, 0)
146
147pl.schr(0, 1)
148x_inclination = 1
149y_inclination = 0
150z_inclination = 0
151x_shear = 0
152for i = 1, NROTATION do
153  omega = 2.*math.pi*(i-1)/NROTATION
154  sin_omega = math.sin(omega)
155  cos_omega = math.cos(omega)
156  y_shear = 0.5*yrange*sin_omega
157  z_shear = 0.5*zrange*cos_omega
158  zs = zsmax - dzsrot * (i-1)
159  pl.ptex3(xmid, ymax, zs,
160           x_inclination, y_inclination, z_inclination,
161           x_shear, y_shear, z_shear,
162           0.5, "rotation for y = y#dmax#u")
163end
164
165pl.schr(0, 1)
166x_inclination = 0
167y_inclination = -1
168z_inclination = 0
169y_shear = 0
170for i = 1, NROTATION do
171  omega = 2.*math.pi*(i-1)/NROTATION
172  sin_omega = math.sin(omega)
173  cos_omega = math.cos(omega)
174  x_shear = 0.5*xrange*sin_omega
175  z_shear = 0.5*zrange*cos_omega
176  zs = zsmax - dzsrot * (i-1)
177  pl.ptex3(xmax, ymid, zs,
178           x_inclination, y_inclination, z_inclination,
179           x_shear, y_shear, z_shear,
180           0.5, "rotation for x = x#dmax#u")
181end
182
183pl.schr(0, 1)
184x_inclination = 1
185y_inclination = 0
186z_inclination = 0
187x_shear = 0
188for i = 1, NROTATION do
189  omega = 2.*math.pi*(i-1)/NROTATION
190  sin_omega = math.sin(omega)
191  cos_omega = math.cos(omega)
192  y_shear = 0.5*yrange*cos_omega
193  z_shear = 0.5*zrange*sin_omega
194  ys = ysmax - dysrot * (i-1)
195  pl.ptex3(xmid, ys, zmin,
196           x_inclination, y_inclination, z_inclination,
197           x_shear, y_shear, z_shear,
198           0.5, "rotation for z = z#dmin#u")
199end
200
201pl.mesh(x, y, z, pl.DRAW_LINEXY)
202
203domega = 0.05
204pl.adv(0)
205pl.vpor(-0.15, 1.15, -0.05, 1.05)
206pl.wind(-1.2, 1.2, -0.8, 1.5)
207pl.w3d(1, 1, 1, xmin, xmax, ymin, ymax, zmin, zmax, 20, 45)
208
209pl.col0(2)
210pl.box3("b", "", xmax-xmin, 0,
211        "b", "", ymax-ymin, 0,
212        "bcd", "", zmax-zmin, 0)
213
214pl.schr(0, 1)
215x_inclination = 1
216y_inclination = 0
217z_inclination = 0
218y_shear = 0
219for i = 1, NSHEAR do
220  omega = domega + 2.*math.pi*(i-1)/NSHEAR
221  sin_omega = math.sin(omega)
222  cos_omega = math.cos(omega)
223  x_shear = 0.5*xrange*sin_omega
224  z_shear = 0.5*zrange*cos_omega
225  zs = zsmax - dzsshear * (i-1)
226  pl.ptex3(xmid, ymax, zs,
227           x_inclination, y_inclination, z_inclination,
228           x_shear, y_shear, z_shear,
229           0.5, "shear for y = y#dmax#u")
230end
231
232pl.schr(0, 1)
233x_inclination = 0
234y_inclination = -1
235z_inclination = 0
236x_shear = 0
237for i = 1, NSHEAR do
238  omega = domega + 2.*math.pi*(i-1)/NSHEAR
239  sin_omega = math.sin(omega)
240  cos_omega = math.cos(omega)
241  y_shear = -0.5*yrange*sin_omega
242  z_shear = 0.5*zrange*cos_omega
243  zs = zsmax - dzsshear * (i-1)
244  pl.ptex3(xmax, ymid, zs,
245           x_inclination, y_inclination, z_inclination,
246           x_shear, y_shear, z_shear,
247           0.5, "shear for x = x#dmax#u")
248end
249
250pl.schr(0, 1)
251x_inclination = 1
252y_inclination = 0
253z_inclination = 0
254z_shear = 0
255for i = 1, NSHEAR do
256  omega = domega + 2.*math.pi*(i-1)/NSHEAR
257  sin_omega = math.sin(omega)
258  cos_omega = math.cos(omega)
259  y_shear = 0.5*yrange*cos_omega
260  x_shear = 0.5*xrange*sin_omega
261  ys = ysmax - dysshear * (i-1)
262  pl.ptex3(xmid, ys, zmin,
263           x_inclination, y_inclination, z_inclination,
264           x_shear, y_shear, z_shear,
265           0.5, "shear for z = z#dmin#u")
266end
267
268pl.mesh(x, y, z, pl.DRAW_LINEXY)
269
270pl.adv(0)
271pl.vpor(-0.15, 1.15, -0.05, 1.05)
272pl.wind(-1.2, 1.2, -0.8, 1.5)
273pl.w3d(1, 1, 1, xmin, xmax, ymin, ymax, zmin, zmax, 40, -30)
274
275pl.col0(2)
276pl.box3("b", "", xmax-xmin, 0,
277        "b", "", ymax-ymin, 0,
278        "bcd", "", zmax-zmin, 0)
279
280pl.schr(0, 1.2)
281domega = 2.*math.pi/string.len(pstring)
282omega = 0
283
284radius = 0.5
285pitch = 1/(2*math.pi)
286
287for i = 1, string.len(pstring) do
288  sin_omega = math.sin(omega)
289  cos_omega = math.cos(omega)
290  xpos = xmid + radius*sin_omega
291  ypos = ymid - radius*cos_omega
292  zpos = zmin + pitch*omega
293
294  -- In general, the inclination is proportional to the derivative of
295  --the position wrt theta.
296  x_inclination = radius*cos_omega
297  y_inclination = radius*sin_omega
298  z_inclination = pitch
299
300  -- The shear vector should be perpendicular to the 3D line with Z
301  -- component maximized, but for low pitch a good approximation is
302  --a constant vector that is parallel to the Z axis.
303  x_shear = 0
304  y_shear = 0
305  z_shear = 1
306  pl.ptex3(xpos, ypos, zpos, x_inclination, y_inclination, z_inclination,
307           x_shear, y_shear, z_shear, 0.5, string.sub(pstring, i, i))
308  omega = omega + domega
309end
310
311pl.mesh(x, y, z, pl.DRAW_LINEXY)
312
313pl.adv(0)
314pl.vpor(-0.15, 1.15, -0.05, 1.05)
315pl.wind(-1.2, 1.2, -0.8, 1.5)
316pl.w3d(1, 1, 1, xmin, xmax, ymin, ymax, zmin, zmax, 20, 45)
317
318pl.col0(2)
319pl.box3("b", "", xmax-xmin, 0,
320        "b", "", ymax-ymin, 0,
321        "bcd", "", zmax-zmin, 0)
322
323pl.schr(0, 1)
324pl.mtex3("xp", 3, 0.5, 0.5, "Arbitrarily displaced")
325pl.mtex3("xp", 4.5, 0.5, 0.5, "primary X-axis label")
326pl.mtex3("xs", -2.5, 0.5, 0.5, "Arbitrarily displaced")
327pl.mtex3("xs", -1, 0.5, 0.5, "secondary X-axis label")
328pl.mtex3("yp", 3, 0.5, 0.5, "Arbitrarily displaced")
329pl.mtex3("yp", 4.5, 0.5, 0.5, "primary Y-axis label")
330pl.mtex3("ys", -2.5, 0.5, 0.5, "Arbitrarily displaced")
331pl.mtex3("ys", -1, 0.5, 0.5, "secondary Y-axis label")
332pl.mtex3("zp", 4.5, 0.5, 0.5, "Arbitrarily displaced")
333pl.mtex3("zp", 3, 0.5, 0.5, "primary Z-axis label")
334pl.mtex3("zs", -2.5, 0.5, 0.5, "Arbitrarily displaced")
335pl.mtex3("zs", -1, 0.5, 0.5, "secondary Z-axis label")
336
337pl.mesh(x, y, z, pl.DRAW_LINEXY)
338
339pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x29.lua
1
2       Sample plots using date / time formatting for axes
3
4  Copyright (C) 2009 Werner Smekal
5
6  This file is part of PLplot.
7
8    PLplot is free software you can redistribute it and/or modify
9  it under the terms of the GNU General Library Public License as published
10  by the Free Software Foundation either version 2 of the License, or
11  (at your option) any later version.
12
13  PLplot is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Library General Public License for more details.
17
18  You should have received a copy of the GNU Library General Public License
19  along with PLplot if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22
23dofile("plplot_examples.lua")
24
25
26
27function plot1()
28  x = {}
29  y = {}
30
31  xerr1 = {}
32  xerr2 = {}
33  yerr1 = {}
34  yerr2 = {}
35  -- Data points every 10 minutes for 1 day
36  npts = 73
37
38  xmin = 0
39  xmax = 60*60*24 -- Number of seconds in a day
40  ymin = 10
41  ymax = 20
42
43  for i = 1, npts do
44    x[i] = xmax*((i-1)/npts)
45    y[i] = 15 - 5*math.cos(2*math.pi*((i-1)/npts))
46    -- Set x error bars to +/- 5 minute
47    xerr1[i] = x[i]-60*5
48    xerr2[i] = x[i]+60*5
49    -- Set y error bars to +/- 0.1 deg C
50    yerr1[i] = y[i]-0.1
51    yerr2[i] = y[i]+0.1
52  end
53
54  pl.adv(0)
55
56  -- Rescale major ticks marks by 0.5
57  pl.smaj(0, 0.5)
58  -- Rescale minor ticks and error bar marks by 0.5
59  pl.smin(0, 0.5)
60
61  pl.vsta()
62  pl.wind(xmin, xmax, ymin, ymax)
63
64  -- Draw a box with ticks spaced every 3 hour in X and 1 degree C in Y.
65  pl.col0(1)
66  -- Set time format to be hours:minutes
67  pl.timefmt("%H:%M")
68  pl.box("bcnstd", 3*60*60, 3, "bcnstv", 1, 5)
69
70  pl.col0(3)
71  pl.lab("Time (hours:mins)", "Temperature (degC)", "@frPLplot Example 29 - Daily temperature")
72
73  pl.col0(4)
74
75  pl.line(x, y)
76  pl.col0(2)
77  pl.errx(xerr1, xerr2, y)
78  pl.col0(3)
79  pl.erry(x, yerr1, yerr2)
80
81  -- Rescale major / minor tick marks back to default
82  pl.smin(0, 1)
83  pl.smaj(0, 1)
84end
85
86
87function plot2()
88  x = {}
89  y = {}
90
91  -- Latitude for London
92  lat = 51.5
93
94  npts = 365
95
96  xmin = 0
97  xmax = npts*60*60*24
98  ymin = 0
99  ymax = 24
100
101  -- Formula for hours of daylight from
102  -- "A Model Comparison for Daylength as a Function of Latitude and
103  -- Day of the Year", 1995, Ecological Modelling, 80, pp 87-95.
104  for j = 1, npts do
105    x[j] = (j-1)*60*60*24
106    p = math.asin(0.39795*math.cos(0.2163108 + 2*math.atan(0.9671396*math.tan(0.00860*(j-1-186)))))
107    d = 24 - (24/math.pi)*
108      math.acos( (math.sin(0.8333*math.pi/180) + math.sin(lat*math.pi/180)*math.sin(p)) /
109        (math.cos(lat*math.pi/180)*math.cos(p)) )
110    y[j] = d
111  end
112
113  pl.col0(1)
114  -- Set time format to be abbreviated month name followed by day of month
115  pl.timefmt("%b %d")
116  pl.prec(1, 1)
117  pl.env(xmin, xmax, ymin, ymax, 0, 40)
118
119
120  pl.col0(3)
121  pl.lab("Date", "Hours of daylight", "@frPLplot Example 29 - Hours of daylight at 51.5N")
122
123  pl.col0(4)
124
125  pl.line(x, y)
126
127  pl.prec(0, 0)
128end
129
130
131function plot3()
132  x = {}
133  y = {}
134
135  tstart = 1133395200
136
137  npts = 62
138
139  xmin = tstart
140  xmax = xmin + npts*60*60*24
141  ymin = 0
142  ymax = 5
143
144  for i = 1, npts do
145    x[i] = xmin + (i-1)*60*60*24
146    y[i] = 1 + math.sin(2*math.pi*(i-1)/7) + math.exp(math.min(i-1,npts-i+1)/31)
147  end
148  pl.adv(0)
149
150  pl.vsta()
151  pl.wind(xmin, xmax, ymin, ymax)
152
153  pl.col0(1)
154  -- Set time format to be ISO 8601 standard YYYY-MM-DD. Note that this is
155  --equivalent to %f for C99 compliant implementations of strftime.
156  pl.timefmt("%Y-%m-%d")
157  -- Draw a box with ticks spaced every 14 days in X and 1 hour in Y.
158  pl.box("bcnstd", 14*24*60*60,14, "bcnstv", 1, 4)
159
160  pl.col0(3)
161  pl.lab("Date", "Hours of television watched", "@frPLplot Example 29 - Hours of television watched in Dec 2005 / Jan 2006")
162
163  pl.col0(4)
164
165  -- Rescale symbol size (used by plpoin) by 0.5
166  pl.ssym(0, 0.5)
167  pl.poin(x, y, 2)
168  pl.line(x, y)
169end
170
171
172function plot4()
173  -- TAI-UTC (seconds) as a function of time.
174  -- Use Besselian epochs as the continuous time interval just to prove
175  -- this does not introduce any issues.
176
177  x = {}
178  y = {}
179
180  -- Use the definition given in http://en.wikipedia.org/wiki/Besselian_epoch
181  -- B = 1900. + (JD -2415020.31352)/365.242198781
182  -- ==> (as calculated with aid of "bc -l" command)
183  -- B = (MJD + 678940.364163900)/365.242198781
184  -- ==>
185  -- MJD = B*365.24219878 - 678940.364163900
186  scale = 365.242198781
187  offset1 = -678940
188  offset2 = -0.3641639
189  pl.configtime(scale, offset1, offset2, 0, 0, 0, 0, 0, 0, 0, 0.)
190
191  for kind = 0, 6 do
192    if kind == 0 then
193      xmin = pl.ctime(1950, 0, 2, 0, 0, 0)
194      xmax = pl.ctime(2020, 0, 2, 0, 0, 0)
195      npts = 70*12 + 1
196      ymin = 0
197      ymax = 36
198      time_format = "%Y%"
199      if_TAI_time_format = 1
200      title_suffix = "from 1950 to 2020"
201      xtitle = "Year"
202      xlabel_step = 10
203    end
204    if kind==1 or kind==2 then
205      xmin = pl.ctime(1961, 7, 1, 0, 0, 1.64757-0.20)
206      xmax = pl.ctime(1961, 7, 1, 0, 0, 1.64757+0.20)
207      npts = 1001
208      ymin = 1.625
209      ymax = 1.725
210      time_format = "%S%2%"
211      title_suffix = "near 1961-08-01 (TAI)"
212      xlabel_step = 0.05/(scale*86400)
213      if kind==1 then
214        if_TAI_time_format = 1
215        xtitle = "Seconds (TAI)"
216      else
217        if_TAI_time_format = 0
218        xtitle = "Seconds (TAI) labelled with corresponding UTC"
219      end
220    end
221    if kind==3 or kind==4 then
222      xmin = pl.ctime(1963, 10, 1, 0, 0, 2.6972788-0.20)
223      xmax = pl.ctime(1963, 10, 1, 0, 0, 2.6972788+0.20)
224      npts = 1001
225      ymin = 2.55
226      ymax = 2.75
227      time_format = "%S%2%"
228      title_suffix = "near 1963-11-01 (TAI)"
229      xlabel_step = 0.05/(scale*86400)
230      if kind==3 then
231                if_TAI_time_format = 1
232                xtitle = "Seconds (TAI)"
233      else
234                if_TAI_time_format = 0
235                xtitle = "Seconds (TAI) labelled with corresponding UTC"
236      end
237    end
238    if kind==5 or kind==6 then
239      xmin = pl.ctime(2009, 0, 1, 0, 0, 34-5)
240      xmax = pl.ctime(2009, 0, 1, 0, 0, 34+5)
241      npts = 1001
242      ymin = 32.5
243      ymax = 34.5
244      time_format = "%S%2%"
245      title_suffix = "near 2009-01-01 (TAI)"
246      xlabel_step = 1/(scale*86400)
247      if kind==5 then
248        if_TAI_time_format = 1
249        xtitle = "Seconds (TAI)"
250      else
251        if_TAI_time_format = 0
252        xtitle = "Seconds (TAI) labelled with corresponding UTC"
253      end
254    end
255
256    for i = 1, npts do
257      x[i] = xmin + (i-1)*(xmax-xmin)/(npts-1)
258      pl.configtime(scale, offset1, offset2, 0, 0, 0, 0, 0, 0, 0, 0)
259      tai = x[i]
260      tai_year, tai_month, tai_day, tai_hour, tai_min, tai_sec = pl.btime(tai)
261      pl.configtime(scale, offset1, offset2, 2, 0, 0, 0, 0, 0, 0, 0)
262      utc_year, utc_month, utc_day, utc_hour, utc_min, utc_sec = pl.btime(tai)
263      pl.configtime(scale, offset1, offset2, 0, 0, 0, 0, 0, 0, 0, 0.)
264      utc = pl.ctime(utc_year, utc_month, utc_day, utc_hour, utc_min, utc_sec)
265      y[i]=(tai-utc)*scale*86400.
266    end
267
268    pl.adv(0)
269    pl.vsta()
270    pl.wind(xmin, xmax, ymin, ymax)
271    pl.col0(1)
272    if if_TAI_time_format ~= 0 then
273      pl.configtime(scale, offset1, offset2, 0, 0, 0, 0, 0, 0, 0, 0)
274    else
275      pl.configtime(scale, offset1, offset2, 2, 0, 0, 0, 0, 0, 0, 0)
276    end
277    pl.timefmt(time_format)
278    pl.box("bcnstd", xlabel_step, 0, "bcnstv", 0., 0)
279    pl.col0(3)
280    title = "@frPLplot Example 29 - TAI-UTC " .. title_suffix
281    pl.lab(xtitle, "TAI-UTC (sec)", title)
282
283    pl.col0(4)
284
285    pl.line(x, y)
286  end
287end
288
289
290pl.parseopts(arg, pl.PL_PARSE_FULL)
291
292pl.init()
293
294pl.sesc('@')
295
296plot1()
297
298plot2()
299
300plot3()
301
302plot4()
303
304pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x30.lua
1
2    Alpha color values demonstration.
3
4  Copyright (C) 2008 Werner Smekal
5
6  This file is part of PLplot.
7
8  PLplot is free software you can redistribute it and/or modify
9  it under the terms of the GNU General Library Public License as published
10  by the Free Software Foundation either version 2 of the License, or
11  (at your option) any later version.
12
13  PLplot is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Library General Public License for more details.
17
18  You should have received a copy of the GNU Library General Public License
19  along with PLplot if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22dofile("plplot_examples.lua")
23
24red = { 0, 255, 0, 0 }
25green = { 0, 0, 255, 0 }
26blue = { 0, 0, 0, 255 }
27alpha = { 1, 1, 1, 1 }
28
29px = { 0.1, 0.5, 0.5, 0.1 }
30py = { 0.1, 0.1, 0.5, 0.5 }
31
32pos = { 0, 1 }
33rcoord = { 1, 1 }
34gcoord = { 0, 0 }
35bcoord = { 0, 0 }
36acoord = { 0, 1 }
37rev = { 0, 0 }
38
39pl.parseopts (arg, pl.PL_PARSE_FULL);
40
41pl.init()
42pl.scmap0n(4)
43pl.scmap0a(red, green, blue, alpha)
44
45
46pl.adv(0)
47pl.vpor(0, 1, 0, 1)
48pl.wind(0, 1, 0, 1)
49pl.col0(0)
50pl.box("", 1, 0, "", 1, 0)
51
52for i = 0, 8 do
53  icol = math.mod(i, 3) + 1
54
55  -- Get a color, change its transparency and
56  -- set it as the current color.
57  r, g, b, a = pl.gcol0a(icol)
58  pl.scol0a(icol, r, g, b, 1-i/9)
59  pl.col0(icol)
60
61  -- Draw the rectangle
62  pl.fill(px, py)
63
64  -- Shift the rectangles coordinates
65  for j = 1, 4 do
66    px[j] = px[j] + 0.5/9
67    py[j] = py[j] + 0.5/9
68  end
69end
70
71
72
73pl.adv(0)
74pl.vpor(0.1, 0.9, 0.1, 0.9)
75pl.wind(0.0, 1.0, 0.0, 1.0)
76
77for i = 0, 4 do
78  -- Set box X position
79  px[1] = 0.05 + 0.2 * i
80  px[2] = px[1] + 0.1
81  px[3] = px[2]
82  px[4] = px[1]
83
84  -- We don't want the boxes to be transparent, so since we changed
85  -- the colors transparencies in the first example we have to change
86  -- the transparencies back to completely opaque.
87  icol = math.mod(i, 3) + 1
88  r, g, b, a = pl.gcol0a(icol)
89  pl.scol0a(icol, r, g, b, 1)
90  pl.col0(icol)
91
92  for j = 0, 4 do
93    -- Set box y position and draw the box.
94    py[1] = 0.05 + 0.2 * j
95    py[2] = py[1]
96    py[3] = py[1] + 0.1
97    py[4] = py[3]
98    pl.fill(px, py)
99  end
100end
101
102pl.scmap1n(128)
103pl.scmap1la(1, pos, rcoord, gcoord, bcoord, acoord, rev)
104
105px[1] = 0.
106px[2] = 1.
107px[3] = 1.
108px[4] = 0.
109
110py[1] = 0.
111py[2] = 0.
112py[3] = 1.
113py[4] = 1.
114
115pl.gradient(px, py, 90.)
116
117pl.plend()
nanonote-example-files/example-files/data/Examples/lua-plplot-examples/x31.lua
1
2  Copyright (C) 2008 Werner Smekal
3
4  set/get tester
5
6  This file is part of PLplot.
7
8  PLplot is free software you can redistribute it and/or modify
9  it under the terms of the GNU General Library Public License as published
10  by the Free Software Foundation either version 2 of the License, or
11  (at your option) any later version.
12
13  PLplot is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Library General Public License for more details.
17
18  You should have received a copy of the GNU Library General Public License
19  along with PLplot if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22
23dofile("plplot_examples.lua")
24
25r1 = { 0, 255 }
26g1 = { 255, 0 }
27b1 = { 0, 0 }
28a1 = { 1, 1 }
29
30status = 0
31pl.parseopts(arg, pl.PL_PARSE_FULL)
32
33fam0, num0, bmax0 = pl.gfam()
34fam1 = 0
35num1 = 10
36bmax1 = 1000
37pl.sfam(fam1, num1, bmax1)
38
39fam2, num2, bmax2 = pl.gfam()
40print(string.format("family parameters: fam, num, bmax = %d %d %d", fam2, num2, bmax2))
41if fam2~=fam1 or num2~=num1 or bmax2~=bmax1 then
42  io.stderr:write("plgfam test failed\n")
43  status = 1
44end
45pl.sfam(fam0, num0, bmax0)
46
47xp0, yp0, xleng0, yleng0, xoff0, yoff0 = pl.gpage()
48xp1 = 200.
49yp1 = 200.
50xleng1 = 400
51yleng1 = 200
52xoff1 = 10
53yoff1 = 20
54pl.spage(xp1, yp1, xleng1, yleng1, xoff1, yoff1)
55
56xp2, yp2, xleng2, yleng2, xoff2, yoff2 = pl.gpage()
57print(string.format("page parameters: xp, yp, xleng, yleng, xoff, yoff = %f %f %d %d %d %d", xp2, yp2, xleng2, yleng2, xoff2, yoff2))
58if xp2~=xp1 or yp2~=yp1 or xleng2~=xleng1 or yleng2~=yleng1 or xoff2~=xoff1 or yoff2~=yoff1 then
59  io.stderr:write("plgpage test failed\n")
60  status = 1
61end
62pl.spage(xp0, yp0, xleng0, yleng0, xoff0, yoff0)
63
64compression1 = 95
65pl.scompression(compression1)
66
67pl.init()
68
69compression2 = pl.gcompression()
70print("Output various PLplot parameters")
71print("compression parameter = " .. compression2)
72if compression2~=compression1 then
73  io.stderr:write("plgcompression test failed\n")
74  status = 1
75end
76
77
78pl.scolor(1)
79pl.scol0(1, 255, 0, 0)
80pl.scmap1(r1, g1, b1)
81pl.scmap1a(r1, g1, b1, a1)
82
83level2 = pl.glevel()
84print("level parameter = " .. level2)
85if level2~=1 then
86  io.stderr:write("plglevel test failed.\n")
87  status = 1
88end
89
90pl.adv(0)
91pl.vpor(0.01, 0.99, 0.02, 0.49)
92xmin, xmax, ymin, ymax = pl.gvpd()
93print(string.format("plvpor: xmin, xmax, ymin, ymax = %f %f %f %f", xmin, xmax, ymin, ymax))
94if xmin~=0.01 or xmax~=0.99 or ymin~=0.02 or ymax~=0.49 then
95  io.stderr:write("plgvpd test failed\n")
96  status = 1
97end
98xmid = 0.5*(xmin+xmax)
99ymid = 0.5*(ymin+ymax)
100
101pl.wind(0.2, 0.3, 0.4, 0.5)
102xmin, xmax, ymin, ymax = pl.gvpw()
103print(string.format("plwind: xmin, xmax, ymin, ymax = %f %f %f %f", xmin, xmax, ymin, ymax))
104if xmin~=0.2 or xmax~=0.3 or ymin~=0.4 or ymax~=0.5 then
105  io.stderr:write("plgvpw test failed\n")
106  status = 1
107end
108
109wx, wy, win = pl.calc_world(xmid,ymid)
110print(string.format("world parameters: wx, wy, win = %f %f %d", wx, wy, win))
111if math.abs(wx-0.5*(xmin+xmax))>1.0e-5 or math.abs(wy-0.5*(ymin+ymax))>1.0e-5 then
112  io.stderr:write("plcalc_world test failed\n")
113  status = 1
114end
115
116fnam = pl.gfnam()
117if fnam=="" then
118  print("No output file name is set")
119else
120  print("Output file name read")
121end
122io.stderr:write(string.format("Output file name is %s\n",fnam))
123
124pl.sxax(3,0)
125digmax, digits = pl.gxax()
126print(string.format("x axis parameters: digmax, digits = %d %d", digmax, digits))
127if digmax~=3 then
128  io.stderr:write("plgxax test failed\n")
129  status = 1
130end
131
132pl.syax(4,0)
133digmax, digits = pl.gyax()
134print(string.format("y axis parameters: digmax, digits = %d %d", digmax, digits))
135if digmax~=4 then
136  io.stderr:write("plgyax test failed\n")
137  status = 1
138end
139
140pl.szax(5,0)
141digmax,digits = pl.gzax()
142print(string.format("z axis parameters: digmax, digits = %d %d", digmax, digits))
143if digmax~=5 then
144  io.stderr:write("plgzax test failed\n")
145  status = 1
146end
147
148pl.sdidev(0.05, pl.PL_NOTSET, 0.1, 0.2)
149mar, aspect, jx, jy = pl.gdidev()
150print(string.format("device-space window parameters: mar, aspect, jx, jy = %f %f %f %f" , mar, aspect, jx, jy))
151if mar~=0.05 or jx~=0.1 or jy~=0.2 then
152  io.stderr:write("plgdidev test failed\n")
153  status = 1
154end
155
156pl.sdiori(1.0)
157ori = pl.gdiori()
158print(string.format("ori parameter = %f", ori))
159if ori~=1.0 then
160  io.stderr:write("plgdiori test failed\n")
161  status = 1
162end
163
164pl.sdiplt(0.1, 0.2, 0.9, 0.8)
165xmin, ymin, xmax, ymax = pl.gdiplt()
166print(string.format("plot-space window parameters: xmin, ymin, xmax, ymax = %f %f %f %f", xmin, ymin, xmax, ymax))
167if xmin~=0.1 or xmax~=0.9 or ymin~=0.2 or ymax~=0.8 then
168  io.stderr:write("plgdiplt test failed\n")
169  status = 1
170end
171
172pl.sdiplz(0.1, 0.1, 0.9, 0.9)
173zxmin, zymin, zxmax, zymax = pl.gdiplt()
174print(string.format("zoomed plot-space window parameters: xmin, ymin, xmax, ymax = %f %f %f %f", zxmin, zymin, zxmax, zymax))
175if math.abs(zxmin -(xmin + (xmax-xmin)*0.1)) > 1.0e-5 or
176   math.abs(zxmax -(xmin+(xmax-xmin)*0.9)) > 1.0e-5 or
177   math.abs(zymin -(ymin+(ymax-ymin)*0.1)) > 1.0e-5 or
178   math.abs(zymax -(ymin+(ymax-ymin)*0.9)) > 1.0e-5 then
179  io.stderr:write("plsdiplz test failed\n")
180  status = 1
181end
182
183pl.scolbg(10, 20, 30)
184r, g, b = pl.gcolbg()
185print(string.format("background colour parameters: r, g, b = %d %d %d", r, g, b))
186if r~=10 or g~=20 or b~=30 then
187  io.stderr:write("plgcolbg test failed\n")
188  status = 1
189end
190
191pl.scolbga(20, 30, 40, 0.5)
192r, g, b, a = pl.gcolbga()
193print(string.format("background/transparency colour parameters: r, g, b, a = %d %d %d %f", r, g, b, a))
194if r~=20 or g~=30 or b~=40 or a~=0.5 then
195  io.stderr:write("plgcolbga test failed\n")
196  status = 1
197end
198
199pl.plend()
nanonote-example-files/example-files/data/Music/Camille_Saint-Saens_-_introduction_et_rondo_capriccioso,_op._28.ogg
nanonote-example-files/example-files/data/Music/README
1the Music files can found at:
2  http://commons.wikimedia.org/wiki/File:Camille_Saint-Saens_-_introduction_et_rondo_capriccioso,_op._28.ogg
nanonote-example-files/script-files/usr/bin/mtd.nn
1#!/bin/bash
2
3if [ "$1" == "flash" ] && [ "$#" == "3" ]; then
4    case "$2" in
5    "bootloader")
6    echo "not implenment"
7    #flash_eraseall /dev/mtd0
8    exit 0
9    ;;
10    "kernel")
11    echo "flashing kernel ..."
12    flash_eraseall /dev/mtd1
13    nandwrite -p /dev/mtd1 "$3"
14    exit 0
15    ;;
16    "rootfs")
17    echo "flashing rootfs ..."
18    ubiformat /dev/mtd2 -f "$3"
19    exit 0
20    ;;
21    "data")
22    echo "flashing data partition ..."
23    ubiformat /dev/mtd3 -f "$3"
24    exit 0
25    ;;
26    esac
27fi
28
29if [ "$1" == "mount" ] && [ "$#" == "3" ]; then
30    MOUNT_POINT="$3"
31
32    if [ "$2" == "rootfs" ]; then
33    PARTITION="2"
34    elif [ "$2" == "data" ]; then
35    PARTITION="3"
36    fi
37
38    ubiattach /dev/ubi_ctrl -m ${PARTITION}
39    DEV_UBI=`dmesg | grep "UBI: attached mtd${PARTITION} to" | cut -d ":" -f 2 | cut -d " " -f 5`
40    mkdir -p $MOUNT_POINT
41    if [ -d "$3" ]; then
42    echo "$3 not a folder"
43    exit 1
44    fi
45
46    mount -t ubifs ${DEV_UBI}_0 $MOUNT_POINT
47fi
48
49
50if [ "$1" == "format_data" ]; then
51    ubiformat /dev/mtd3 -y
52    ubiattach /dev/ubi_ctrl -m 3
53    ubimkvol /dev/ubi1 -s 1730MiB -N data
54    exit 0
55fi
56
57if [ "$1" == "fw_setenv_default" ]; then
58    fw_setenv bootargs mem=32M console=tty0 console=ttyS0,57600n8 ubi.mtd=2 rootfstype=ubifs root=ubi0:rootfs rw rootwait
59    fw_setenv bootcmd nand read 0x80600000 0x400000 0x200000\;bootm
60    fw_setenv bootargsfromsd mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p1 rw rootwait
61    fw_setenv bootcmdfromsd mmc init\; ext2load mmc 0 0x80600000 /boot/uImage\; bootm
62    fw_setenv bootdelay 0
63    fw_setenv baudrate 57600
64    fw_setenv loads_echo 1
65    fw_setenv stdin serial
66    fw_setenv stderr serial
67    fw_setenv stdout serial
68    exit 0
69fi
70
71echo "\
72Usage: $0 [-d <version>] [-l <path to local images>] [-h]
73     -d <> I will download and flash a specific version of OpenWrt images
74
75     -l <> I will flash images present in <arg>
76            (missing files will be skipped)
77
78     -h you already found out
79
80OpenWrt reflash script for qi-hardware Ben NanoNote
81written by: Xiangfu Liu (xiangfu@sharism.cc)
82
83                                                     version: ${__VERSION__}
84Please report bugs to developer@lists.qi-hardware.com"
85exit 1
nanonote-files/Makefile
1include $(TOPDIR)/rules.mk
2
3PKG_NAME:=nanonote-files
4PKG_VERSION:=1.0
5
6include $(INCLUDE_DIR)/package.mk
7
8define Package/nanonote-files/Default
9    MAINTAINER:="Xiangfu Liu" <xiangfu@sharism.cc>
10    TITLE:=NanoNote Files
11    SECTION:=utils
12    CATEGORY:=Utilities
13endef
14
15define Package/nanonote-example-files
16    $(call Package/nanonote-files/Default)
17    TITLE+=(Example Files)
18endef
19
20define Package/nanonote-script-files
21    $(call Package/nanonote-files/Default)
22    TITLE+=(Script Files)
23endef
24
25define Build/Compile
26endef
27
28define Package/nanonote-example-files/install
29    $(CP) ./example-files/* $(1)/
30endef
31
32define Package/nanonote-script-files/install
33    $(CP) ./script-files/* $(1)/
34endef
35
36$(eval $(call BuildPackage,nanonote-example-files))
37$(eval $(call BuildPackage,nanonote-script-files))
nanonote-files/example-files/data/Examples/lua-plplot-examples/plplot_examples.lua
1-- initialise Lua bindings for PLplot examples.
2if string.sub(_VERSION,1,7)=='Lua 5.0' then
3    lib=loadlib('/home/pub/spock/src/qi/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/plplot-5.9.7/bindings/lua/plplotluac.so','luaopen_plplotluac') or
4      loadlib('/home/pub/spock/src/qi/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/plplot-5.9.7/bindings/lua/plplotluac.dll','luaopen_plplotluac') or
5      loadlib('/home/pub/spock/src/qi/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/plplot-5.9.7/bindings/lua/plplotluac.dylib','luaopen_plplotluac')
6    assert(lib)()
7else
8    package.cpath = '/home/pub/spock/src/qi/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/plplot-5.9.7/bindings/lua/?.so;' ..
9                  '/home/pub/spock/src/qi/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/plplot-5.9.7/bindings/lua/?.dll;' ..
10                  '/home/pub/spock/src/qi/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/plplot-5.9.7/bindings/lua/?.dylib;' ..package.cpath
11    require('plplotluac')
12end
nanonote-files/example-files/data/Examples/lua-plplot-examples/x01.lua
1--[[ $Id: x01.lua 9414 2009-01-29 22:48:54Z airwin $
2
3    Simple line plot and multiple windows demo.
4
5  Copyright (C) 2008 Werner Smekal
6
7  This file is part of PLplot.
8
9  PLplot is free software you can redistribute it and/or modify
10  it under the terms of the GNU General Library Public License as published
11  by the Free Software Foundation either version 2 of the License, or
12  (at your option) any later version.
13
14  PLplot is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Library General Public License for more details.
18
19  You should have received a copy of the GNU Library General Public License
20  along with PLplot if not, write to the Free Software
21  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22--]]
23
24-- initialise Lua bindings for PLplot examples.
25dofile("plplot_examples.lua")
26
27-- Variables and data arrays used by plot generators
28x = {}
29y = {}
30xs = {}
31ys = {}
32
33fontset = 1
34f_name = ""
35
36
37function plot1(do_test)
38  for i = 1, 60 do
39    x[i] = xoff + xscale * (i) / 60
40    y[i] = yoff + yscale * x[i]^2
41  end
42
43  xmin = x[1]
44  xmax = x[60]
45  ymin = y[1]
46  ymax = y[60]
47
48  for i = 1, 6 do
49    xs[i] = x[(i-1) * 10 + 4]
50    ys[i] = y[(i-1) * 10 + 4]
51  end
52
53  -- Set up the viewport and window using PLENV. The range in X is
54  -- 0.0 to 6.0, and the range in Y is 0.0 to 30.0. The axes are
55  -- scaled separately (just = 0), and we just draw a labelled
56  -- box (axis = 0).
57  pl.col0(1)
58  pl.env(xmin, xmax, ymin, ymax, 0, 0)
59  pl.col0(2)
60  pl.lab("(x)", "(y)", "#frPLplot Example 1 - y=x#u2")
61
62  -- Plot the data points
63  pl.col0(4)
64  pl.poin(xs, ys, 9)
65
66  -- Draw the line through the data
67  pl.col0(3)
68  pl.line(x, y)
69end
70
71
72function plot2()
73  -- Set up the viewport and window using PLENV. The range in X is -2.0 to
74  -- 10.0, and the range in Y is -0.4 to 2.0. The axes are scaled separately
75  --(just = 0), and we draw a box with axes (axis = 1).
76  pl.col0(1)
77  pl.env(-2, 10, -0.4, 1.2, 0, 1)
78  pl.col0(2)
79  pl.lab("(x)", "sin(x)/x", "#frPLplot Example 1 - Sinc Function")
80
81  -- Fill up the arrays
82  for i=1, 100 do
83    x[i] = (i - 20) / 6
84    y[i] = 1
85    if x[i] ~= 0 then y[i] = math.sin(x[i])/x[i] end
86  end
87
88  -- Draw the line
89  pl.col0(3)
90  pl.wid(2)
91  pl.line(x, y)
92  pl.wid(1)
93end
94
95
96function plot3()
97  space0 = { }
98  mark0 = { }
99  space1 = { 1500 }
100  mark1 = { 1500 }
101
102  -- For the final graph we wish to override the default tick intervals, and
103  --so do not use plenv().
104  pl.adv(0)
105
106  -- Use standard viewport, and define X range from 0 to 360 degrees, Y range
107  --from -1.2 to 1.2.
108  pl.vsta()
109  pl.wind(0, 360, -1.2, 1.2)
110
111  -- Draw a box with ticks spaced 60 degrees apart in X, and 0.2 in Y.
112  pl.col0(1)
113  pl.box("bcnst", 60, 2, "bcnstv", 0.2, 2)
114
115  -- Superimpose a dashed line grid, with 1.5 mm marks and spaces.
116  -- plstyl expects a pointer!
117  pl.styl(mark1, space1)
118  pl.col0(2)
119  pl.box("g", 30, 0, "g", 0.2, 0)
120  pl.styl(mark0, space0)
121
122  pl.col0(3)
123  pl.lab("Angle (degrees)", "sine", "#frPLplot Example 1 - Sine function")
124
125  for i=1, 101 do
126    x[i] = 3.6*(i-1)
127    y[i] = math.sin(x[i]*math.pi/180)
128  end
129
130  pl.col0(4)
131  pl.line(x, y)
132end
133
134
135----------------------------------------------------------------------------
136-- main
137--
138-- Generates several simple line plots. Demonstrates:
139-- - subwindow capability
140-- - setting up the window, drawing plot, and labelling
141-- - changing the color
142-- - automatic axis rescaling to exponential notation
143-- - placing the axes in the middle of the box
144-- - gridded coordinate axes
145----------------------------------------------------------------------------
146
147-- plplot initialization
148
149-- Parse and process command line arguments
150pl.parseopts(arg, pl.PL_PARSE_FULL)
151
152-- Get version number, just for kicks
153ver=pl.gver()
154print("PLplot library version: " .. ver)
155
156-- Initialize plplot
157-- Divide page into 2x2 plots
158-- Note: calling plstar replaces separate calls to plssub and plinit
159pl.star(2,2)
160
161-- Select font set as per input flag
162if fontset ~= 0 then
163    pl.fontld(1)
164else
165    pl.fontld(0)
166end
167
168-- Set up the data
169-- Original case
170xscale = 6
171yscale = 1
172xoff = 0
173yoff = 0
174
175-- Do a plot
176plot1(0)
177
178-- Set up the data
179xscale = 1
180yscale = 0.0014
181yoff = 0.0185
182
183-- Do a plot
184digmax = 5
185pl.syax(digmax, 0)
186
187plot1(1)
188plot2()
189plot3()
190
191-- Show how to save a plot:
192-- Open a new device, make it current, copy parameters,
193-- and replay the plot buffer
194if f_name~="" then -- command line option '-save filename'
195  print("The current plot was saved in color Postscript under the name " .. f_name .. ".\n")
196  cur_strm = pl.gstrm() -- get current stream
197  new_strm = pl.mkstrm() -- create a new one
198
199  pl.sfnam(f_name) -- file name
200  pl.sdev("psc") -- device type
201
202  pl.cpstrm(cur_strm, 0) -- copy old stream parameters to new stream
203  pl.replot() -- do the save by replaying the plot buffer
204  pl.plend1() -- finish the device
205
206  pl.sstrm(cur_strm) -- return to previous stream
207end
208
209-- Don't forget to call plend() to finish off!
210pl.plend()
nanonote-files/example-files/data/Examples/lua-plplot-examples/x02.lua
1--[[ $Id: x02.lua 9414 2009-01-29 22:48:54Z airwin $
2
3    Multiple window and color map 0 demo.
4
5  Copyright (C) 2008 Werner Smekal
6
7  This file is part of PLplot.
8
9  PLplot is free software you can redistribute it and/or modify
10  it under the terms of the GNU General Library Public License as published
11  by the Free Software Foundation either version 2 of the License, or
12  (at your option) any later version.
13
14  PLplot is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Library General Public License for more details.
18
19  You should have received a copy of the GNU Library General Public License
20  along with PLplot if not, write to the Free Software
21  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22--]]
23
24-- initialise Lua bindings for PLplot examples.
25dofile("plplot_examples.lua")
26
27----------------------------------------------------------------------------
28-- draw_windows
29--
30-- Draws a set of numbered boxes with colors according to cmap0 entry.
31----------------------------------------------------------------------------
32
33function draw_windows(nw, cmap0_offset)
34  pl.schr(0, 3.5)
35  pl.font(4)
36
37  for i = 0, nw-1 do
38    pl.col0(i+cmap0_offset)
39    pl.adv(0)
40    vmin = 0.1
41    vmax = 0.9
42    for j = 0, 2 do
43      pl.wid(j + 1)
44      pl.vpor(vmin, vmax, vmin, vmax)
45      pl.wind(0, 1, 0, 1)
46      pl.box("bc", 0, 0, "bc", 0, 0)
47      vmin = vmin + 0.1
48      vmax = vmax - 0.1
49    end
50    pl.wid(1)
51    pl.ptex(0.5, 0.5, 1, 0, 0.5, tostring(i))
52  end
53end
54
55
56----------------------------------------------------------------------------
57-- demo1
58--
59-- Demonstrates multipl.e windows and default color map 0 palette.
60----------------------------------------------------------------------------
61
62function demo1()
63  pl.bop()
64
65  -- Divide screen into 16 regions
66  pl.ssub(4, 4)
67
68  draw_windows(16, 0)
69
70  pl.eop()
71end
72
73
74----------------------------------------------------------------------------
75-- demo2
76--
77-- Demonstrates multipl.e windows, user-modified color map 0 palette, and
78-- HLS -> RGB translation.
79----------------------------------------------------------------------------
80
81function demo2()
82  -- Set up cmap0
83  -- Use 100 custom colors in addition to base 16
84  r = {}
85  g = {}
86  b = {}
87
88  -- Min & max lightness values
89  lmin = 0.15
90  lmax = 0.85
91
92  pl.bop()
93
94  -- Divide screen into 100 regions
95
96  pl.ssub(10, 10)
97
98  for i = 0, 99 do
99    -- Bounds on HLS, from pl.hlsrgb() commentary --
100    -- hue [0., 360.] degrees
101    -- lightness [0., 1.] magnitude
102    -- saturation [0., 1.] magnitude
103
104    -- Vary hue uniformly from left to right
105    h = (360/10) * math.mod(i, 10)
106
107    -- Vary lightness uniformly from top to bottom, between min & max
108    l = lmin + (lmax - lmin) * math.floor(i/10)/9
109
110    -- Use max saturation
111    s = 1
112
113    r1, g1, b1 = pl.hlsrgb(h, l, s)
114
115    -- Use 255.001 to avoid close truncation decisions in this example.
116    r[i+1+16] = r1 * 255.001
117    g[i+1+16] = g1 * 255.001
118    b[i+1+16] = b1 * 255.001
119  end
120
121  -- Load default cmap0 colors into our custom set
122  for i = 0, 15 do
123    r[i+1], g[i+1], b[i+1] = pl.gcol0(i)
124  end
125
126  -- Now set cmap0 all at once (faster, since fewer driver calls)
127  pl.scmap0(r, g, b)
128
129  draw_windows(100, 16)
130
131  pl.eop()
132end
133
134
135----------------------------------------------------------------------------
136-- main
137--
138-- Demonstrates multipl.e windows and color map 0 palette, both default and
139-- user-modified.
140----------------------------------------------------------------------------
141
142-- Parse and process command line arguments
143pl.parseopts(arg, pl.PL_PARSE_FULL)
144
145-- Initialize pl.pl.ot
146pl.init()
147
148-- Run demos
149demo1()
150demo2()
151
152pl.plend()
nanonote-files/example-files/data/Examples/lua-plplot-examples/x03.lua
1--[[ $Id: x03.lua 10613 2009-11-19 12:05:09Z andrewross $
2
3    Polar plot demo.
4
5  Copyright (C) 2008 Werner Smekal
6
7  This file is part of PLplot.
8
9  PLplot is free software you can redistribute it and/or modify
10  it under the terms of the GNU General Library Public License as published
11  by the Free Software Foundation either version 2 of the License, or
12  (at your option) any later version.
13
14  PLplot is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Library General Public License for more details.
18
19  You should have received a copy of the GNU Library General Public License
20  along with PLplot if not, write to the Free Software
21  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22--]]
23
24-- initialise Lua bindings for PLplot examples.
25dofile("plplot_examples.lua")
26
27----------------------------------------------------------------------------
28-- main
29--
30-- Generates polar plot, with 1-1 scaling.
31----------------------------------------------------------------------------
32
33x0 = {}
34y0 = {}
35x = {}
36y = {}
37
38dtr = math.pi/180
39for i = 1, 361 do
40  x0[i] = math.cos(dtr * (i-1))
41  y0[i] = math.sin(dtr * (i-1))
42end
43
44-- Parse and process command line arguments
45
46pl.parseopts(arg, pl.PL_PARSE_FULL)
47
48-- Set orientation to portrait - note not all device drivers
49-- support this, in particular most interactive drivers do not
50pl.sori(1)
51
52-- Initialize plplot
53pl.init()
54
55-- Set up viewport and window, but do not draw box
56pl.env(-1.3, 1.3, -1.3, 1.3, 1, -2)
57
58-- Draw circles for polar grid
59for i = 1, 10 do
60        pl.arc(0, 0, 0.1*i, 0.1*i, 0, 360, 0);
61end
62
63pl.col0(2)
64for i=1, 12 do
65    theta = 30 * (i-1)
66    dx = math.cos(dtr * theta)
67    dy = math.sin(dtr * theta)
68
69  -- Draw radial spokes for polar grid
70
71    pl.join(0, 0, dx, dy)
72
73  -- Write labels for angle
74    if theta < 9.99 then
75      offset = 0.45
76    else
77    if theta < 99.9 then
78      offset = 0.30
79    else
80      offset = 0.15
81    end
82    end
83
84  -- Slightly off zero to avoid floating point logic flips at 90 and 270 deg.
85    if dx >= -0.00001 then
86        pl.ptex(dx, dy, dx, dy, -offset, tostring(math.floor(theta)))
87    else
88        pl.ptex(dx, dy, -dx, -dy, 1.+offset, tostring(math.floor(theta)))
89  end
90end
91
92-- Draw the graph
93for i=1, 361 do
94  r = math.sin(dtr * (5*(i-1)))
95  x[i] = x0[i] * r
96  y[i] = y0[i] * r
97end
98pl.col0(3)
99pl.line(x, y)
100
101pl.col0(4)
102pl.mtex("t", 2, 0.5, 0.5, "#frPLplot Example 3 - r(#gh)=sin 5#gh")
103
104-- Close the plot at end
105pl.plend()
nanonote-files/example-files/data/Examples/lua-plplot-examples/x04.lua
1--[[ $Id: x04.lua 9414 2009-01-29 22:48:54Z airwin $
2
3    Log plot demo.
4    Simple line plot and multiple windows demo.
5
6  Copyright (C) 2008 Werner Smekal
7
8  This file is part of PLplot.
9
10  PLplot is free software you can redistribute it and/or modify
11  it under the terms of the GNU General Library Public License as published
12  by the Free Software Foundation either version 2 of the License, or
13  (at your option) any later version.
14
15  PLplot is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Library General Public License for more details.
19
20  You should have received a copy of the GNU Library General Public License
21  along with PLplot if not, write to the Free Software
22  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23--]]
24
25-- initialise Lua bindings for PLplot examples.
26dofile("plplot_examples.lua")
27
28----------------------------------------------------------------------------
29-- plot1
30--
31-- Log-linear plot.
32----------------------------------------------------------------------------
33
34function plot1(type)
35  freql = {}
36  ampl = {}
37  phase = {}
38
39  pl.adv(0)
40
41  -- Set up data for log plot
42  f0 = 1
43  for i=1, 101 do
44    freql[i] = -2 + (i-1) / 20
45    freq = 10^freql[i]
46    ampl[i] = 20 * math.log10(1 / math.sqrt(1 + (freq / f0)^2))
47    phase[i] = -(180 / math.pi) * math.atan(freq / f0)
48  end
49
50  pl.vpor(0.15, 0.85, 0.1, 0.9)
51  pl.wind(-2, 3, -80, 0)
52
53  -- Try different axis and labelling styles.
54  pl.col0(1)
55  if type == 0 then
56    pl.box("bclnst", 0, 0, "bnstv", 0, 0)
57  end
58
59  if type == 1 then
60    pl.box("bcfghlnst", 0, 0, "bcghnstv", 0, 0)
61  end
62
63  -- Plot ampl vs freq
64  pl.col0(2)
65  pl.line(freql, ampl)
66  pl.col0(1)
67  pl.ptex(1.6, -30, 1, -20, 0.5, "-20 dB/decade")
68
69  -- Put labels on
70  pl.col0(1)
71  pl.mtex("b", 3.2, 0.5, 0.5, "Frequency")
72  pl.mtex("t", 2, 0.5, 0.5, "Single Pole Low-Pass Filter")
73  pl.col0(2)
74  pl.mtex("l", 5, 0.5, 0.5, "Amplitude (dB)")
75
76  -- For the gridless case, put phase vs freq on same plot
77  if type == 0 then
78    pl.col0(1)
79    pl.wind(-2, 3, -100, 0)
80    pl.box("", 0, 0, "cmstv", 30, 3)
81    pl.col0(3)
82    pl.line(freql, phase)
83    pl.col0(3)
84    pl.mtex("r", 5, 0.5, 0.5, "Phase shift (degrees)")
85  end
86end
87
88
89----------------------------------------------------------------------------
90-- main
91--
92-- Illustration of logarithmic axes, and redefinition of window.
93----------------------------------------------------------------------------
94
95-- Parse and process command line arguments
96pl.parseopts(arg, pl.PL_PARSE_FULL)
97
98-- Initialize plplot
99pl.init()
100pl.font(2)
101
102-- Make log plots using two different styles.
103plot1(0)
104plot1(1)
105
106pl.plend()
nanonote-files/example-files/data/Examples/lua-plplot-examples/x05.lua
1--[[ $Id: x05.lua 9414 2009-01-29 22:48:54Z airwin $
2
3    Histogram demo.
4
5  Copyright (C) 2008 Werner Smekal
6
7  This file is part of PLplot.
8
9  PLplot is free software you can redistribute it and/or modify
10  it under the terms of the GNU General Library Public License as published
11  by the Free Software Foundation either version 2 of the License, or
12  (at your option) any later version.
13
14  PLplot is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Library General Public License for more details.
18
19  You should have received a copy of the GNU Library General Public License
20  along with PLplot if not, write to the Free Software
21  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22--]]
23
24-- initialise Lua bindings for PLplot examples.
25dofile("plplot_examples.lua")
26
27--------------------------------------------------------------------------
28-- main
29--
30-- Draws a histogram from sample data.
31--------------------------------------------------------------------------
32
33NPTS=2047
34data = {}
35
36-- Parse and process command line arguments
37pl.parseopts(arg, pl.PL_PARSE_FULL);
38
39-- Initialize plplot
40pl.init()
41
42-- Fill up data points
43delta = 2.0*math.pi/NPTS
44for i=1, NPTS do
45  data[i] = math.sin((i-1)*delta)
46end
47
48pl.col0(1)
49pl.hist(data, -1.1, 1.1, 44, 0)
50pl.col0(2)
51pl.lab("#frValue", "#frFrequency",
52         "#frPLplot Example 5 - Probability function of Oscillator")
53
54pl.plend()
nanonote-files/example-files/data/Examples/lua-plplot-examples/x06.lua
1--[[ $Id: x06.lua 11032 2010-05-27 22:34:40Z andrewross $
2
3    Font demo.
4
5  Copyright (C) 2008 Werner Smekal
6
7  This file is part of PLplot.
8
9  PLplot is free software you can redistribute it and/or modify
10  it under the terms of the GNU General Library Public License as published
11  by the Free Software Foundation either version 2 of the License, or
12  (at your option) any later version.
13
14  PLplot is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Library General Public License for more details.
18
19  You should have received a copy of the GNU Library General Public License
20  along with PLplot if not, write to the Free Software
21  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22--]]
23
24-- initialise Lua bindings for PLplot examples.
25dofile("plplot_examples.lua")
26
27----------------------------------------------------------------------------
28-- main
29--
30-- Displays the entire "plpoin" symbol (font) set.
31----------------------------------------------------------------------------
32
33-- Parse and process command line arguments
34pl.parseopts(arg, pl.PL_PARSE_FULL)
35
36-- Initialize plplot
37pl.init()
38
39for kind_font = 0,1 do
40  pl.fontld( kind_font )
41  if kind_font == 0 then
42    maxfont = 1
43  else
44    maxfont = 4
45  end
46
47  for font = 1,maxfont do
48    pl.font( font )
49    pl.adv(0)
50
51    -- Set up viewport and window
52    pl.col0(2)
53    pl.vpor(0.1, 1, 0.1, 0.9)
54    pl.wind(0, 1, 0, 1.3)
55
56    -- Draw the grid using plbox
57    pl.box("bcg", 0.1, 0, "bcg", 0.1, 0)
58
59    -- Write the digits below the frame
60    pl.col0(15)
61    for i=0, 9 do
62      pl.mtex("b", 1.5, (0.1 * i + 0.05), 0.5, tostring(i))
63    end
64
65    k = 0
66    x = {}
67    y ={}
68    for i = 0, 12 do
69      -- Write the digits to the left of the frame
70      pl.mtex("lv", 1, (1 - (2 * i + 1) / 26), 1, tostring(10*i))
71      for j = 0, 9 do
72        x[1] = 0.1 * j + 0.05
73        y[1] = 1.25 - 0.1 * i
74
75        -- Display the symbols
76        if k < 128 then
77          pl.poin(x, y, k)
78        end
79        k = k + 1
80      end
81    end
82
83    if kind_font == 0 then
84      pl.mtex("t", 1.5, 0.5, 0.5, "PLplot Example 6 - plpoin symbols (compact)")
85    else
86      pl.mtex("t", 1.5, 0.5, 0.5, "PLplot Example 6 - plpoin symbols (extended)")
87    end
88  end
89end
90pl.plend()
nanonote-files/example-files/data/Examples/lua-plplot-examples/x07.lua
1--[[ $Id: x07.lua 11032 2010-05-27 22:34:40Z andrewross $
2
3    Font demo.
4
5  Copyright (C) 2008 Werner Smekal
6
7  This file is part of PLplot.
8
9  PLplot is free software you can redistribute it and/or modify
10  it under the terms of the GNU General Library Public License as published
11  by the Free Software Foundation either version 2 of the License, or
12  (at your option) any later version.
13
14  PLplot is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Library General Public License for more details.
18
19  You should have received a copy of the GNU Library General Public License
20  along with PLplot if not, write to the Free Software
21  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22--]]
23
24-- initialise Lua bindings for PLplot examples.
25dofile("plplot_examples.lua")
26
27base = { 0, 100, 0, 100, 200, 500, 600, 700, 800, 900,
28         2000, 2100, 2200, 2300, 2400, 2500,
29                 2600, 2700, 2800, 2900 }
30
31----------------------------------------------------------------------------
32-- main
33--
34-- Displays the entire "plsym" symbol (font) set.
35----------------------------------------------------------------------------
36
37-- Parse and process command line arguments
38pl.parseopts(arg, pl.PL_PARSE_FULL)
39
40-- Initialize plplot
41pl.init()
42
43pl.fontld(0)
44for l = 1, 20 do
45
46    if l == 3 then
47        pl.fontld(1)
48    end
49    pl.adv(0)
50
51    -- Set up viewport and window
52    pl.col0(2)
53    pl.vpor(0.15, 0.95, 0.1, 0.9)
54    pl.wind(0, 1, 0, 1)
55
56    -- Draw the grid using plbox
57
58    pl.box("bcg", 0.1, 0, "bcg", 0.1, 0)
59
60    -- Write the digits below the frame
61
62    pl.col0(15)
63    for i = 0, 9 do
64        pl.mtex("b", 1.5, (0.1 * i + 0.05), 0.5, tostring(i))
65    end
66
67    k = 0
68    x = {}
69    y = {}
70    for i = 0, 9 do
71        -- Write the digits to the left of the frame
72        pl.mtex("lv", 1.0, (0.95 - 0.1 * i), 1.0, tostring(base[l] + 10 * i))
73        for j=0, 9 do
74            x[1] = 0.1 * j + 0.05
75            y[1] = 0.95 - 0.1 * i
76
77            -- Display the symbols
78            pl.sym(x, y, base[l] + k)
79            k = k + 1
80        end
81    end
82
83    if l <= 2 then
84        pl.mtex("t", 1.5, 0.5, 0.5, "PLplot Example 7 - PLSYM symbols (compact)")
85    else
86        pl.mtex("t", 1.5, 0.5, 0.5, "PLplot Example 7 - PLSYM symbols (extended)")
87    end
88end
89
90pl.plend()
nanonote-files/example-files/data/Examples/lua-plplot-examples/x08.lua
1--[[ $Id: x08.lua 9533 2009-02-16 22:18:37Z smekal $
2
3    3-d plot demo.
4
5  Copyright (C) 2008 Werner Smekal
6
7  This file is part of PLplot.
8
9  PLplot is free software you can redistribute it and/or modify
10  it under the terms of the GNU General Library Public License as published
11  by the Free Software Foundation either version 2 of the License, or
12  (at your option) any later version.
13
14  PLplot is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Library General Public License for more details.
18
19  You should have received a copy of the GNU Library General Public License
20  along with PLplot if not, write to the Free Software
21  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22--]]
23
24-- initialise Lua bindings for PLplot examples.
25dofile("plplot_examples.lua")
26
27
28-- bitwise or operator from http://lua-users.org/wiki/BaseSixtyFour
29-- (c) 2006-2008 by Alex Kloss
30-- licensed under the terms of the LGPL2
31
32-- return single bit (for OR)
33function bit(x,b)
34    return (math.mod(x, 2^b) - math.mod(x,2^(b-1)) > 0)
35end
36
37-- logic OR for number values
38function lor(x,y)
39    result = 0
40    for p=1,8 do result = result + (((bit(x,p) or bit(y,p)) == true) and 2^(p-1) or 0) end
41    return result
42end
43
44
45----------------------------------------------------------------------------
46-- cmap1_init1
47--
48-- Initializes color map 1 in HLS space.
49-- Basic grayscale variation from half-dark (which makes more interesting
50-- looking plot compared to dark) to light.
51-- An interesting variation on this:
52-- s[1] = 1.0
53----------------------------------------------------------------------------
54
55function cmap1_init(gray)
56  i = { 0, 1 } -- left and right boundary
57
58  if gray ~= 0 then
59    h = { 0, 0 } -- hue -- low: red (arbitrary if s=0), high: red (arbitrary if s=0)
60    l = { 0.5, 1 } -- lightness -- low: half-dark, high: light
61    s = { 0, 0 } -- minimum saturation
62  else
63    h = { 240, 0 } -- blue -> green -> yellow -> red
64    l = { 0.6, 0.6 }
65    s = { 0.8, 0.8 }
66  end
67
68  pl.scmap1n(256)
69  pl.scmap1l(0, i, h, l, s)
70end
71
72
73----------------------------------------------------------------------------
74-- main
75--
76-- Does a series of 3-d plots for a given data set, with different
77-- viewing options in each plot.
78----------------------------------------------------------------------------
79
80XPTS = 35 -- Data points in x
81YPTS = 46 -- Data points in y
82LEVELS = 10
83
84alt = { 60, 20 }
85az = { 30, 60 }
86
87title = {
88    "#frPLplot Example 8 - Alt=60, Az=30",
89    "#frPLplot Example 8 - Alt=20, Az=60"
90}
91
92clevel = {}
93nlevel = LEVELS
94rosen = 1
95sombrero = 0
96
97-- Parse and process command line arguments
98pl.parseopts(arg, pl.PL_PARSE_FULL)
99if sombrero ~= 0 then rosen=0 end
100
101-- Initialize plplot
102pl.init()
103
104-- Allocate data structures
105x = {}
106y = {}
107z = {}
108
109for i=1, XPTS do
110  x[i] = (i-1-math.floor(XPTS/2)) / math.floor(XPTS/2)
111  if rosen~=0 then x[i]=x[i]*1.5 end
112end
113
114for i=1, YPTS do
115  y[i] = (i-1-math.floor(YPTS/2)) / math.floor(YPTS/2)
116  if rosen~=0 then y[i]=y[i]+0.5 end
117end
118
119for i=1, XPTS do
120  xx = x[i]
121  z[i]= {}
122  for j=1, YPTS do
123    yy = y[j]
124    if rosen~=0 then
125      z[i][j] = (1-xx)^2 + 100*(yy-xx^2)^2
126      -- The log argument may be zero for just the right grid.
127      if z[i][j] > 0 then
128        z[i][j] = math.log(z[i][j])
129      else
130        z[i][j] = -5 -- MAXFLOAT would mess-up up the scale
131      end
132    else
133      r = math.sqrt(xx^2 + yy^2)
134      z[i][j] = math.exp(-r^2) * math.cos(2*math.pi*r)
135    end
136  end
137end
138
139zmax, zmin = pl.MinMax2dGrid(z)
140step = (zmax-zmin)/(nlevel+1)
141for i=1, nlevel do
142  clevel[i] = zmin + step + step*(i-1)
143end
144
145pl.lightsource(1, 1, 1)
146
147for k=1, 2 do
148  for ifshade = 1, 4 do
149    pl.adv(0)
150    pl.vpor(0, 1, 0, 0.9)
151    pl.wind(-1, 1, -0.9, 1.1)
152    pl.col0(3)
153    pl.mtex("t", 1, 0.5, 0.5, title[k])
154    pl.col0(1)
155    if rosen~=0 then
156      pl.w3d(1, 1, 1, -1.5, 1.5, -0.5, 1.5, zmin, zmax, alt[k], az[k])
157    else
158      pl.w3d(1, 1, 1, -1, 1, -1, 1, zmin, zmax, alt[k], az[k])
159    end
160
161    pl.box3("bnstu", "x axis", 0, 0,
162           "bnstu", "y axis", 0, 0,
163           "bcdmnstuv", "z axis", 0, 0)
164    pl.col0(2)
165
166    if ifshade==1 then -- diffuse light surface plot
167      cmap1_init(1)
168      pl.surf3d(x, y, z, 0, clevel)
169    end
170
171    if ifshade==2 then -- magnitude colored plot
172      cmap1_init(0)
173      pl.surf3d(x, y, z, pl.MAG_COLOR, {})
174    end
175
176    if ifshade==3 then -- magnitude colored plot with faceted squares
177      cmap1_init(0)
178      pl.surf3d(x, y, z, lor(pl.MAG_COLOR, pl.FACETED), {})
179    end
180
181    if ifshade==4 then -- magnitude colored plot with contours
182      cmap1_init(0)
183      pl.surf3d(x, y, z, lor(lor(pl.MAG_COLOR, pl.SURF_CONT), pl.BASE_CONT), clevel)
184    end
185  end
186end
187
188-- Clean up
189pl.plend()
nanonote-files/example-files/data/Examples/lua-plplot-examples/x09.lua
1--[[ $Id: x09.lua 9533 2009-02-16 22:18:37Z smekal $
2
3    Contour plot demo.
4
5  Copyright (C) 2008 Werner Smekal
6
7  This file is part of PLplot.
8
9  PLplot is free software you can redistribute it and/or modify
10  it under the terms of the GNU General Library Public License as published
11  by the Free Software Foundation either version 2 of the License, or
12  (at your option) any later version.
13
14  PLplot is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Library General Public License for more details.
18
19  You should have received a copy of the GNU Library General Public License
20  along with PLplot if not, write to the Free Software
21  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22--]]
23
24-- initialise Lua bindings for PLplot examples.
25dofile("plplot_examples.lua")
26
27XPTS = 35 -- Data points in x
28YPTS = 46 -- Data points in y
29
30XSPA = 2/(XPTS-1)
31YSPA = 2/(YPTS-1)
32
33-- polar plot data
34PERIMETERPTS = 100
35RPTS = 40
36THETAPTS = 40
37
38-- potential plot data
39PPERIMETERPTS = 100
40PRPTS = 40
41PTHETAPTS = 64
42PNLEVEL = 20
43
44clevel = { -1, -0.8, -0.6, -0.4, -0.2, 0, 0.2, 0.4, 0.6, 0.8, 1}
45
46-- Transformation function
47tr = { XSPA, 0, -1, 0, YSPA, -1 }
48
49function mypltr(x, y)
50    tx = tr[1] * x + tr[2] * y + tr[3]
51    ty = tr[4] * x + tr[5] * y + tr[6]
52
53    return tx, ty
54end
55
56--polar contour plot example.
57function polar()
58    px = {}
59    py = {}
60    lev = {}
61
62    pl.env(-1, 1, -1, 1, 0, -2)
63    pl.col0(1)
64
65    --Perimeter
66    for i=1, PERIMETERPTS do
67        t = (2*math.pi/(PERIMETERPTS-1))*(i-1)
68        px[i] = math.cos(t)
69        py[i] = math.sin(t)
70  end
71  pl.line(px, py)
72
73    --create data to be contoured.
74  cgrid2["xg"] = {}
75  cgrid2["yg"] = {}
76  cgrid2["nx"] = RPTS
77  cgrid2["ny"] = THETAPTS
78  z = {}
79
80  for i = 1, RPTS do
81    r = (i-1)/(RPTS-1)
82    cgrid2["xg"][i] = {}
83    cgrid2["yg"][i] = {}
84    z[i] = {}
85    for j = 1, THETAPTS do
86      theta = (2*math.pi/(THETAPTS-1))*(j-1)
87      cgrid2["xg"][i][j] = r*math.cos(theta)
88      cgrid2["yg"][i][j] = r*math.sin(theta)
89      z[i][j] = r
90    end
91  end
92
93  for i = 1, 10 do
94    lev[i] = 0.05 + 0.10*(i-1)
95  end
96
97  pl.col0(2)
98  pl.cont(z, 1, RPTS, 1, THETAPTS, lev, "pltr2", cgrid2)
99  pl.col0(1)
100  pl.lab("", "", "Polar Contour Plot")
101end
102
103
104----------------------------------------------------------------------------
105-- f2mnmx
106--
107-- Returns min & max of input 2d array.
108----------------------------------------------------------------------------
109function f2mnmx(f, nx, ny)
110    fmax = f[1][1]
111    fmin = fmax
112
113    for i=1, nx do
114        for j=1, ny do
115        fmax = math.max(fmax, f[i][j])
116        fmin = math.min(fmin, f[i][j])
117        end
118    end
119
120    return fmin, fmax
121end
122
123
124--shielded potential contour plot example.
125function potential()
126  clevelneg = {}
127  clevelpos = {}
128  px = {}
129  py = {}
130
131  --create data to be contoured.
132  cgrid2["xg"] = {}
133  cgrid2["yg"] = {}
134  cgrid2["nx"] = PRPTS
135  cgrid2["ny"] = PTHETAPTS
136  z = {}
137
138  for i = 1, PRPTS do
139    r = 0.5 + (i-1)
140    cgrid2["xg"][i] = {}
141    cgrid2["yg"][i] = {}
142    for j = 1, PTHETAPTS do
143      theta = 2*math.pi/(PTHETAPTS-1)*(j-0.5)
144      cgrid2["xg"][i][j] = r*math.cos(theta)
145      cgrid2["yg"][i][j] = r*math.sin(theta)
146    end
147  end
148
149  rmax = PRPTS-0.5
150  xmin, xmax = f2mnmx(cgrid2["xg"], PRPTS, PTHETAPTS)
151  ymin, ymax = f2mnmx(cgrid2["yg"], PRPTS, PTHETAPTS)
152  x0 = (xmin + xmax)/2
153  y0 = (ymin + ymax)/2
154
155  -- Expanded limits
156  peps = 0.05
157  xpmin = xmin - math.abs(xmin)*peps
158  xpmax = xmax + math.abs(xmax)*peps
159  ypmin = ymin - math.abs(ymin)*peps
160  ypmax = ymax + math.abs(ymax)*peps
161
162  -- Potential inside a conducting cylinder (or sphere) by method of images.
163  -- Charge 1 is placed at (d1, d1), with image charge at (d2, d2).
164  -- Charge 2 is placed at (d1, -d1), with image charge at (d2, -d2).
165  -- Also put in smoothing term at small distances.
166  eps = 2
167  q1 = 1
168  d1 = rmax/4
169
170  q1i = - q1*rmax/d1
171  d1i = rmax^2/d1
172
173  q2 = -1
174  d2 = rmax/4
175
176  q2i = - q2*rmax/d2
177  d2i = rmax^2/d2
178
179  for i = 1, PRPTS do
180    z[i] = {}
181    for j = 1, PTHETAPTS do
182      div1 = math.sqrt((cgrid2.xg[i][j]-d1)^2 + (cgrid2.yg[i][j]-d1)^2 + eps^2)
183      div1i = math.sqrt((cgrid2.xg[i][j]-d1i)^2 + (cgrid2.yg[i][j]-d1i)^2 + eps^2)
184      div2 = math.sqrt((cgrid2.xg[i][j]-d2)^2 + (cgrid2.yg[i][j]+d2)^2 + eps^2)
185      div2i = math.sqrt((cgrid2.xg[i][j]-d2i)^2 + (cgrid2.yg[i][j]+d2i)^2 + eps^2)
186      z[i][j] = q1/div1 + q1i/div1i + q2/div2 + q2i/div2i
187    end
188  end
189  zmin, zmax = f2mnmx(z, PRPTS, PTHETAPTS)
190
191  -- Positive and negative contour levels.
192  dz = (zmax-zmin)/PNLEVEL
193  nlevelneg = 1
194  nlevelpos = 1
195  for i = 1, PNLEVEL do
196    clevel = zmin + (i-0.5)*dz
197    if clevel <= 0 then
198      clevelneg[nlevelneg] = clevel
199      nlevelneg = nlevelneg + 1
200    else
201      clevelpos[nlevelpos] = clevel
202      nlevelpos = nlevelpos + 1
203    end
204  end
205
206  -- Colours!
207  ncollin = 11
208  ncolbox = 1
209  ncollab = 2
210
211  -- Finally start plotting this page!
212  pl.adv(0)
213  pl.col0(ncolbox)
214
215  pl.vpas(0.1, 0.9, 0.1, 0.9, 1)
216  pl.wind(xpmin, xpmax, ypmin, ypmax)
217  pl.box("", 0, 0, "", 0, 0)
218
219  pl.col0(ncollin)
220  if nlevelneg>1 then
221    -- Negative contours
222    pl.lsty(2)
223    pl.cont(z, 1, PRPTS, 1, PTHETAPTS, clevelneg, "pltr2", cgrid2)
224  end
225
226  if nlevelpos>1 then
227    -- Positive contours
228    pl.lsty(1)
229    pl.cont(z, 1, PRPTS, 1, PTHETAPTS, clevelpos, "pltr2", cgrid2)
230  end
231
232  -- Draw outer boundary
233  for i = 1, PPERIMETERPTS do
234    t = (2*math.pi/(PPERIMETERPTS-1))*(i-1)
235    px[i] = x0 + rmax*math.cos(t)
236    py[i] = y0 + rmax*math.sin(t)
237  end
238
239  pl.col0(ncolbox)
240  pl.line(px, py)
241
242  pl.col0(ncollab)
243  pl.lab("", "", "Shielded potential of charges in a conducting sphere")
244end
245
246
247----------------------------------------------------------------------------
248-- main
249--
250-- Does several contour plots using different coordinate mappings.
251----------------------------------------------------------------------------
252mark = { 1500 }
253space = { 1500 }
254
255-- Parse and process command line arguments
256pl.parseopts(arg, pl.PL_PARSE_FULL)
257
258-- Initialize plplot
259pl.init()
260
261-- Set up function arrays
262z = {}
263w = {}
264
265for i = 1, XPTS do
266    xx = (i-1 - math.floor(XPTS/2)) / math.floor(XPTS/2)
267  z[i] = {}
268  w[i] = {}
269    for j = 1, YPTS do
270        yy = (j-1 - math.floor(YPTS/2)) / math.floor(YPTS/2) - 1
271        z[i][j] = xx^2 - yy^2
272        w[i][j] = 2 * xx * yy
273    end
274end
275
276-- Set up grids
277cgrid1 = {}
278cgrid1["xg"] = {}
279cgrid1["yg"] = {}
280cgrid1["nx"] = XPTS
281cgrid1["ny"] = YPTS
282cgrid2 = {}
283cgrid2["xg"] = {}
284cgrid2["yg"] = {}
285cgrid2["nx"] = XPTS
286cgrid2["ny"] = YPTS
287
288for i = 1, XPTS do
289  cgrid2["xg"][i] = {}
290  cgrid2["yg"][i] = {}
291    for j = 1, YPTS do
292    xx, yy = mypltr(i-1, j-1)
293
294    argx = xx * math.pi/2
295    argy = yy * math.pi/2
296    distort = 0.4
297
298    cgrid1["xg"][i] = xx + distort * math.cos(argx)
299    cgrid1["yg"][j] = yy - distort * math.cos(argy)
300
301    cgrid2["xg"][i][j] = xx + distort * math.cos(argx) * math.cos(argy)
302    cgrid2["yg"][i][j] = yy - distort * math.cos(argx) * math.cos(argy)
303  end
304end
305
306-- Plot using identity transform
307pl.setcontlabelformat(4, 3)
308pl.setcontlabelparam(0.006, 0.3, 0.1, 1)
309pl.env(-1, 1, -1, 1, 0, 0)
310pl.col0(2)
311pl.cont(z, 1, XPTS, 1, YPTS, clevel, "mypltr")
312pl.styl(mark, space)
313pl.col0(3)
314pl.cont(w, 1, XPTS, 1, YPTS, clevel, "mypltr")
315pl.styl({}, {})
316pl.col0(1)
317pl.lab("X Coordinate", "Y Coordinate", "Streamlines of flow")
318pl.setcontlabelparam(0.006, 0.3, 0.1, 0)
319
320-- Plot using 1d coordinate transform
321pl.env(-1, 1, -1, 1, 0, 0)
322pl.col0(2)
323pl.cont(z, 1, XPTS, 1, YPTS, clevel, "pltr1", cgrid1)
324pl.styl(mark, space)
325pl.col0(3)
326pl.cont(w, 1, XPTS, 1, YPTS, clevel, "pltr1", cgrid1)
327pl.styl({}, {})
328pl.col0(1)
329pl.lab("X Coordinate", "Y Coordinate", "Streamlines of flow")
330
331-- Plot using 2d coordinate transform
332pl.env(-1, 1, -1, 1, 0, 0)
333pl.col0(2)
334pl.cont(z, 1, XPTS, 1, YPTS, clevel, "pltr2", cgrid2)
335
336pl.styl(mark, space)
337pl.col0(3)
338pl.cont(w, 1, XPTS, 1, YPTS, clevel, "pltr2", cgrid2)
339pl.styl({}, {})
340pl.col0(1)
341pl.lab("X Coordinate", "Y Coordinate", "Streamlines of flow")
342
343pl.setcontlabelparam(0.006, 0.3, 0.1, 0)
344polar()
345
346pl.setcontlabelparam(0.006, 0.3, 0.1, 0)
347potential()
348
349-- Clean up
350pl.plend()
nanonote-files/example-files/data/Examples/lua-plplot-examples/x10.lua
1--[[ $Id: x10.lua 9414 2009-01-29 22:48:54Z airwin $
2
3    Window positioning demo.
4
5  Copyright (C) 2008 Werner Smekal
6
7  This file is part of PLplot.
8
9  PLplot is free software you can redistribute it and/or modify
10  it under the terms of the GNU General Library Public License as published
11  by the Free Software Foundation either version 2 of the License, or
12  (at your option) any later version.
13
14  PLplot is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Library General Public License for more details.
18
19  You should have received a copy of the GNU Library General Public License
20  along with PLplot if not, write to the Free Software
21  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22--]]
23
24-- initialise Lua bindings for PLplot examples.
25dofile("plplot_examples.lua")
26
27
28----------------------------------------------------------------------------
29-- main
30--
31-- Demonstrates absolute positioning of graphs on a page.
32----------------------------------------------------------------------------
33
34-- Parse and process command line arguments
35pl.parseopts(arg, pl.PL_PARSE_FULL);
36
37-- Initialize plplot
38pl.init()
39
40pl.adv(0)
41pl.vpor(0.0, 1.0, 0.0, 1.0)
42pl.wind(0.0, 1.0, 0.0, 1.0)
43pl.box("bc", 0.0, 0, "bc", 0.0, 0)
44
45pl.svpa(50.0, 150.0, 50.0, 100.0)
46pl.wind(0.0, 1.0, 0.0, 1.0)
47pl.box("bc", 0.0, 0, "bc", 0.0, 0)
48pl.ptex(0.5, 0.5, 1.0, 0.0, 0.5, "BOX at (50,150,50,100)")
49pl.plend()
nanonote-files/example-files/data/Examples/lua-plplot-examples/x11.lua
1--[[ $Id: x11.lua 9533 2009-02-16 22:18:37Z smekal $
2
3    Mesh plot demo.
4
5  Copyright (C) 2008 Werner Smekal
6
7  This file is part of PLplot.
8
9  PLplot is free software you can redistribute it and/or modify
10  it under the terms of the GNU General Library Public License as published
11  by the Free Software Foundation either version 2 of the License, or
12  (at your option) any later version.
13
14  PLplot is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Library General Public License for more details.
18
19  You should have received a copy of the GNU Library General Public License
20  along with PLplot if not, write to the Free Software
21  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22--]]
23
24-- initialise Lua bindings for PLplot examples.
25dofile("plplot_examples.lua")
26
27XPTS = 35 -- Data points in x
28YPTS = 46 -- Data points in y
29LEVELS = 10
30
31opt = { pl.DRAW_LINEXY, pl.DRAW_LINEXY }
32
33alt = { 33, 17 }
34az = { 24, 115 }
35
36title = {
37    "#frPLplot Example 11 - Alt=33, Az=24, Opt=3",
38    "#frPLplot Example 11 - Alt=17, Az=115, Opt=3" }
39
40
41-- bitwise or operator from http://lua-users.org/wiki/BaseSixtyFour
42-- (c) 2006-2008 by Alex Kloss
43-- licensed under the terms of the LGPL2
44
45-- return single bit (for OR)
46function bit(x,b)
47    return (math.mod(x, 2^b) - math.mod(x,2^(b-1)) > 0)
48end
49
50-- logic OR for number values
51function lor(x,y)
52    result = 0
53    for p=1,8 do result = result + (((bit(x,p) or bit(y,p)) == true) and 2^(p-1) or 0) end
54    return result
55end
56
57
58function cmap1_init()
59  i = { 0, 1 } -- left boundary , right boundary
60  h = { 240, 0 } -- blue -> green -> yellow -> red
61  l = { 0.6, 0.6 }
62  s = { 0.8, 0.8 }
63
64  pl.scmap1n(256)
65  pl.scmap1l(0, i, h, l, s)
66end
67
68
69----------------------------------------------------------------------------
70-- main
71--
72-- Does a series of mesh plots for a given data set, with different
73-- viewing options in each plot.
74----------------------------------------------------------------------------
75
76nlevel = LEVELS
77clevel = {}
78
79-- Parse and process command line arguments
80pl.parseopts(arg, pl.PL_PARSE_FULL)
81
82-- Initialize plplot
83pl.init()
84
85x = {}
86y = {}
87z = {}
88
89for i=1, XPTS do
90  x[i] = 3 * (i-1-math.floor(XPTS/2)) / math.floor(XPTS/2)
91end
92
93for i=1, YPTS do
94  y[i] = 3 * (i-1-math.floor(YPTS/2)) / math.floor(YPTS/2)
95end
96
97for i=1, XPTS do
98  xx = x[i]
99  z[i] = {}
100  for j=1, YPTS do
101    yy = y[j]
102    z[i][j] = 3 * (1-xx)^2 * math.exp(-xx^2 - (yy+1.)^2) -
103              10 * (xx/5 - xx^3 - yy^5) * math.exp(-xx^2-yy^2) -
104              1/3 * math.exp(-(xx+1)^2 - yy^2)
105
106    -- Jungfraujoch/Interlaken
107    if false then
108      if z[i][j] < -1 then z[i][j] = -1 end
109    end
110  end
111end
112
113zmax, zmin = pl.MinMax2dGrid(z)
114step = (zmax - zmin)/(nlevel+1)
115for i=1, nlevel do
116  clevel[i] = zmin + step + step*(i-1)
117end
118
119cmap1_init()
120for k=1, 2 do
121  for i=1, 4 do
122    pl.adv(0)
123    pl.col0(1)
124    pl.vpor(0, 1, 0, 0.9)
125    pl.wind(-1, 1, -1, 1.5)
126    pl.w3d(1, 1, 1.2, -3, 3, -3, 3, zmin, zmax, alt[k], az[k])
127    pl.box3("bnstu", "x axis", 0, 0,
128            "bnstu", "y axis", 0, 0,
129            "bcdmnstuv", "z axis", 0, 4)
130
131    pl.col0(2)
132
133    -- wireframe plot
134    if i==1 then
135      pl.mesh(x, y, z, opt[k])
136    end
137
138    -- magnitude colored wireframe plot
139    if i==2 then
140      pl.mesh(x, y, z, lor(opt[k], pl.MAG_COLOR))
141    end
142
143    -- magnitude colored wireframe plot with sides
144    if i==3 then
145      pl.plot3d(x, y, z, lor(opt[k], pl.MAG_COLOR), 1)
146    end
147
148    -- magnitude colored wireframe plot with base contour
149    if i==4 then
150      pl.meshc(x, y, z, lor(lor(opt[k], pl.MAG_COLOR), pl.BASE_CONT), clevel)
151    end
152
153    pl.col0(3)
154    pl.mtex("t", 1, 0.5, 0.5, title[k])
155  end
156end
157
158-- Clean up
159
160pl.plend()
nanonote-files/example-files/data/Examples/lua-plplot-examples/x12.lua
1--[[ $Id: x12.lua 9533 2009-02-16 22:18:37Z smekal $
2
3    Bar chart demo.
4
5  Copyright (C) 2008 Werner Smekal
6
7  This file is part of PLplot.
8
9  PLplot is free software you can redistribute it and/or modify
10  it under the terms of the GNU General Library Public License as published
11  by the Free Software Foundation either version 2 of the License, or
12  (at your option) any later version.
13
14  PLplot is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Library General Public License for more details.
18
19  You should have received a copy of the GNU Library General Public License
20  along with PLplot if not, write to the Free Software
21  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22--]]
23
24-- initialise Lua bindings for PLplot examples.
25dofile("plplot_examples.lua")
26
27function pl.fbox(x0, y0)
28  x = { x0, x0, x0+1,x0+1 }
29  y = { 0, y0, y0, 0 }
30
31  pl.fill(x, y);
32  pl.col0(1);
33  pl.lsty(1);
34  pl.line(x, y);
35end
36
37--------------------------------------------------------------------------
38-- main
39--
40-- Does a simple bar chart, using color fill. If color fill is
41-- unavailable, pattern fill is used instead (automatic).
42--------------------------------------------------------------------------
43
44y0 = {}
45
46pos = { 0, 0.25, 0.5, 0.75, 1 }
47red = { 0, 0.25, 0.5, 1, 1 }
48green = { 1, 0.5, 0.5, 0.5, 1 }
49blue = { 1, 1, 0.5, 0.25, 0 }
50
51
52-- Parse and process command line arguments
53
54pl.parseopts(arg, pl.PL_PARSE_FULL);
55
56-- Initialize plplot
57pl.init()
58
59pl.adv(0)
60pl.vsta()
61pl.wind(1980, 1990, 0, 35)
62pl.box("bc", 1, 0, "bcnv", 10, 0)
63pl.col0(2)
64pl.lab("Year", "Widget Sales (millions)", "#frPLplot Example 12")
65
66y0 = { 5, 15, 12, 24, 28, 30, 20, 8, 12, 3}
67
68pl.scmap1l(1, pos, red, green, blue);
69
70for i=1, 10 do
71    pl.col1((i-1)/9.0);
72    pl.psty(0);
73    pl.fbox((1980+i-1), y0[i]);
74    pl.ptex((1980+i-0.5), (y0[i]+1), 1, 0, 0.5, tostring(y0[i]));
75    pl.mtex("b", 1, (i*0.1-0.05), 0.5, tostring(1980+i-1));
76end
77
78pl.plend();
nanonote-files/example-files/data/Examples/lua-plplot-examples/x13.lua
1--[[ $Id: x13.lua 9526 2009-02-13 22:06:13Z smekal $
2
3    Pie chart demo.
4
5  Copyright (C) 2008 Werner Smekal
6
7  This file is part of PLplot.
8
9  PLplot is free software you can redistribute it and/or modify
10  it under the terms of the GNU General Library Public License as published
11  by the Free Software Foundation either version 2 of the License, or
12  (at your option) any later version.
13
14  PLplot is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Library General Public License for more details.
18
19  You should have received a copy of the GNU Library General Public License
20  along with PLplot if not, write to the Free Software
21  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22--]]
23
24-- initialise Lua bindings for PLplot examples.
25dofile("plplot_examples.lua")
26
27text = { "Maurice", "Geoffrey", "Alan",
28         "Rafael", "Vince" }
29
30--------------------------------------------------------------------------
31-- main
32--
33-- Does a simple pie chart.
34--------------------------------------------------------------------------
35
36per = { 10, 32, 12, 30, 16 }
37
38-- Parse and process command line arguments
39
40pl.parseopts(arg, pl.PL_PARSE_FULL);
41
42-- Initialize plplot
43
44pl.init()
45
46pl.adv(0)
47
48-- Ensure window has aspect ratio of one so circle is
49-- plotted as a circle.
50pl.vasp(1)
51pl.wind(0, 10, 0, 10)
52pl.col0(2)
53
54-- n.b. all theta quantities scaled by 2*M_PI/500 to be integers to avoid
55--floating point logic problems.
56theta0 = 0
57dthet = 1
58for i = 1, 5 do
59  x = { 5 }
60  y = { 5 }
61  j = 2
62  -- n.b. the theta quantities multiplied by 2*math.pi/500 afterward so
63  -- in fact per is interpreted as a percentage.
64    theta1 = theta0 + 5 * per[i]
65    if i == 5 then theta1 = 500 end
66
67    for theta = theta0, theta1, dthet do
68        x[j] = 5 + 3 * math.cos(2*math.pi/500*theta)
69        y[j] = 5 + 3 * math.sin(2*math.pi/500*theta)
70      j = j + 1
71      thetasave=theta
72    end
73    pl.col0(i)
74    pl.psty(math.mod((i + 2), 8) + 1)
75    pl.fill(x, y)
76    pl.col0(1)
77    pl.line(x, y)
78    just = 2*math.pi/500*(theta0 + theta1)/2
79    dx = 0.25 * math.cos(just)
80    dy = 0.25 * math.sin(just)
81    if (theta0 + theta1)<250 or (theta0 + theta1)>750 then
82      just = 0
83    else
84    just = 1
85  end
86
87    pl.ptex((x[(j-1)/2+1] + dx), (y[(j-1)/2+1] + dy), 1, 0, just, text[i]);
88    theta0 = thetasave
89end
90
91pl.font(2)
92pl.schr(0, 1.3)
93pl.ptex(5, 9, 1, 0, 0.5, "Percentage of Sales")
94
95pl.plend()
96
nanonote-files/example-files/data/Examples/lua-plplot-examples/x14.lua
1--[[ $Id: x14.lua 10793 2010-02-06 01:48:39Z hbabcock $
2
3 &n