From: <sm...@us...> - 2009-01-27 08:37:09
|
Revision: 9407 http://plplot.svn.sourceforge.net/plplot/?rev=9407&view=rev Author: smekal Date: 2009-01-27 08:37:04 +0000 (Tue, 27 Jan 2009) Log Message: ----------- Added svn properties. Lua example 1, 8 and 18 are working now. Added partly implemented example 15. Further work on example 22 (still not working). Modified Paths: -------------- trunk/examples/lua/x01.lua trunk/examples/lua/x08.lua trunk/examples/lua/x22.lua Added Paths: ----------- trunk/examples/lua/x15.lua trunk/examples/lua/x18.lua Property Changed: ---------------- trunk/examples/lua/x22.lua Modified: trunk/examples/lua/x01.lua =================================================================== --- trunk/examples/lua/x01.lua 2009-01-27 08:21:33 UTC (rev 9406) +++ trunk/examples/lua/x01.lua 2009-01-27 08:37:04 UTC (rev 9407) @@ -2,7 +2,7 @@ Simple line plot and multiple windows demo. - Copyright (C) 2004 Rafael Laboissiere + Copyright (C) 2008 Werner Smekal This file is part of PLplot. @@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA --]] + -- initialise Lua bindings to PLplot if string.sub(_VERSION,1,7)=='Lua 5.0' then lib=loadlib('./plplotluac.so','luaopen_plplotluac') or loadlib('plplotluac.dll','luaopen_plplotluac') @@ -29,68 +30,115 @@ require('plplotluac') end --- Variables and data arrays used by plot generators +-- Variables and data arrays used by plot generators x = {} y = {} xs = {} ys = {} ---PLGraphicsIn gin fontset = 1 --- Options data structure definition. +f_name = "" -static PLOptionTable options[] = { -{ - "locate", -- Turns on test of API locate function - NULL, - NULL, - &locate_mode, - PL_OPT_BOOL, - "-locate", - "Turns on test of API locate function" }, -{ - "xor", -- Turns on test of xor function - NULL, - NULL, - &test_xor, - PL_OPT_BOOL, - "-xor", - "Turns on test of XOR" }, -{ - "font", -- For switching between font set 1 & 2 - NULL, - NULL, - &fontset, - PL_OPT_INT, - "-font number", - "Selects stroke font set (0 or 1, def:1)" }, -{ - "save", -- For saving in postscript - NULL, - NULL, - &f_name, - PL_OPT_STRING, - "-save filename", - "Save plot in color postscript `file'" }, -{ - NULL, -- option - NULL, -- handler - NULL, -- client data - NULL, -- address of variable to set - 0, -- mode flag - NULL, -- short syntax - NULL } -- long syntax -} -const char *notes[] = {"Make sure you get it right!", NULL} +function plot1(do_test) + for i = 1, 60 do + x[i] = xoff + xscale * (i) / 60 + y[i] = yoff + yscale * x[i]^2 + end --- Function prototypes + xmin = x[1] + xmax = x[60] + ymin = y[1] + ymax = y[60] -void plot1(int) -void plot2(void) -void plot3(void) + for i = 1, 6 do + xs[i] = x[(i-1) * 10 + 4] + ys[i] = y[(i-1) * 10 + 4] + end + -- Set up the viewport and window using PLENV. The range in X is + -- 0.0 to 6.0, and the range in Y is 0.0 to 30.0. The axes are + -- scaled separately (just = 0), and we just draw a labelled + -- box (axis = 0). + pl.col0(1) + pl.env(xmin, xmax, ymin, ymax, 0, 0) + pl.col0(2) + pl.lab("(x)", "(y)", "#frPLplot Example 1 - y=x#u2") + + -- Plot the data points + pl.col0(4) + pl.poin(xs, ys, 9) + + -- Draw the line through the data + pl.col0(3) + pl.line(x, y) +end + + +function plot2() + -- Set up the viewport and window using PLENV. The range in X is -2.0 to + -- 10.0, and the range in Y is -0.4 to 2.0. The axes are scaled separately + --(just = 0), and we draw a box with axes (axis = 1). + pl.col0(1) + pl.env(-2, 10, -0.4, 1.2, 0, 1) + pl.col0(2) + pl.lab("(x)", "sin(x)/x", "#frPLplot Example 1 - Sinc Function") + + -- Fill up the arrays + for i=1, 100 do + x[i] = (i - 20) / 6 + y[i] = 1 + if x[i] ~= 0 then y[i] = math.sin(x[i])/x[i] end + end + + -- Draw the line + pl.col0(3) + pl.wid(2) + pl.line(x, y) + pl.wid(1) +end + + +function plot3() + space0 = { } + mark0 = { } + space1 = { 1500 } + mark1 = { 1500 } + + -- For the final graph we wish to override the default tick intervals, and + --so do not use plenv(). + pl.adv(0) + + -- Use standard viewport, and define X range from 0 to 360 degrees, Y range + --from -1.2 to 1.2. + pl.vsta() + pl.wind(0, 360, -1.2, 1.2) + + -- Draw a box with ticks spaced 60 degrees apart in X, and 0.2 in Y. + pl.col0(1) + pl.box("bcnst", 60, 2, "bcnstv", 0.2, 2) + + -- Superimpose a dashed line grid, with 1.5 mm marks and spaces. + -- plstyl expects a pointer! + pl.styl(mark1, space1) + pl.col0(2) + pl.box("g", 30, 0, "g", 0.2, 0) + pl.styl(mark0, space0) + + pl.col0(3) + pl.lab("Angle (degrees)", "sine", "#frPLplot Example 1 - Sine function") + + for i=1, 101 do + x[i] = 3.6*(i-1) + y[i] = math.sin(x[i]*math.pi/180) + end + + pl.col0(4) + pl.line(x, y) +end + + ---------------------------------------------------------------------------- -- main -- @@ -106,244 +154,64 @@ -- plplot initialization -- Parse and process command line arguments +pl.parseopts(arg, pl.PL_PARSE_FULL) --- plMergeOpts(options, "x01c options", notes) --- plparseopts(&argc, argv, PL_PARSE_FULL) - -- Get version number, just for kicks - -pl.plgver(ver) +ver=pl.gver() print("PLplot library version: " .. ver) -- Initialize plplot -- Divide page into 2x2 plots -- Note: calling plstar replaces separate calls to plssub and plinit -pl.plstar(2,2) +pl.star(2,2) -- Select font set as per input flag - -if fontset != 0 then - pl.plfontld(1) +if fontset ~= 0 then + pl.fontld(1) else - pl.plfontld(0) + pl.fontld(0) end -- Set up the data -- Original case +xscale = 6 +yscale = 1 +xoff = 0 +yoff = 0 - xscale = 6. - yscale = 1. - xoff = 0. - yoff = 0. - -- Do a plot +plot1(0) - plot1(0) - -- Set up the data +xscale = 1 +yscale = 0.0014 +yoff = 0.0185 - xscale = 1. - yscale = 0.0014 - yoff = 0.0185 - -- Do a plot +digmax = 5 +pl.syax(digmax, 0) - digmax = 5 - plsyax(digmax, 0) +plot1(1) +plot2() +plot3() - plot1(1) +-- Show how to save a plot: +-- Open a new device, make it current, copy parameters, +-- and replay the plot buffer +if f_name~="" then -- command line option '-save filename' + print("The current plot was saved in color Postscript under the name " .. f_name .. ".\n") + cur_strm = pl.gstrm() -- get current stream + new_strm = pl.mkstrm() -- create a new one - plot2() + pl.sfnam(f_name) -- file name + pl.sdev("psc") -- device type - plot3() + pl.cpstrm(cur_strm, 0) -- copy old stream parameters to new stream + pl.replot() -- do the save by replaying the plot buffer + pl.plend1() -- finish the device - -- - * Show how to save a plot: - * Open a new device, make it current, copy parameters, - * and replay the plot buffer - + pl.sstrm(cur_strm) -- return to previous stream +end - if (f_name) { -- command line option '-save filename' - - printf("The current plot was saved in color Postscript under the name `%s'.\n", f_name) - plgstrm(&cur_strm) -- get current stream - plmkstrm(&new_strm) -- create a new one - - plsfnam(f_name) -- file name - plsdev("psc") -- device type - - plcpstrm(cur_strm, 0) -- copy old stream parameters to new stream - plreplot() -- do the save by replaying the plot buffer - plend1() -- finish the device - - plsstrm(cur_strm) -- return to previous stream - } - --- Let's get some user input - - if (locate_mode) { - for () { - if (! plGetCursor(&gin)) break - if (gin.keysym == PLK_Escape) break - - pltext() - if (gin.keysym < 0xFF && isprint(gin.keysym)) - printf("subwin = %d, wx = %f, wy = %f, dx = %f, dy = %f, c = '%c'\n", - gin.subwindow, gin.wX, gin.wY, gin.dX, gin.dY, gin.keysym) - else - printf("subwin = %d, wx = %f, wy = %f, dx = %f, dy = %f, c = 0x%02x\n", - gin.subwindow, gin.wX, gin.wY, gin.dX, gin.dY, gin.keysym) - - plgra() - } - } - - plclear() -- Don't forget to call plend() to finish off! - - plend() - exit(0) -} - - -- =============================================================== - -void -plot1(int do_test) -{ - int i - PLFLT xmin, xmax, ymin, ymax - - for (i = 0 i < 60 i++) { - x[i] = xoff + xscale * (i + 1) / 60.0 - y[i] = yoff + yscale * pow(x[i], 2.) - } - - xmin = x[0] - xmax = x[59] - ymin = y[0] - ymax = y[59] - - for (i = 0 i < 6 i++) { - xs[i] = x[i * 10 + 3] - ys[i] = y[i * 10 + 3] - } - --- Set up the viewport and window using PLENV. The range in X is - * 0.0 to 6.0, and the range in Y is 0.0 to 30.0. The axes are - * scaled separately (just = 0), and we just draw a labelled - * box (axis = 0). - - plcol0(1) - plenv(xmin, xmax, ymin, ymax, 0, 0) - plcol0(2) - pllab("(x)", "(y)", "#frPLplot Example 1 - y=x#u2") - --- Plot the data points - - plcol0(4) - plpoin(6, xs, ys, 9) - --- Draw the line through the data - - plcol0(3) - plline(60, x, y) - --- xor mode enable erasing a line/point/text by replotting it again --- it does not work in double buffering mode, however - - if (do_test && test_xor) { -#ifdef PL_HAVE_USLEEP - PLINT st - plxormod(1, &st) -- enter xor mode - if (st) { - for (i=0 i<60 i++) { - plpoin(1, x+i, y+i,9) -- draw a point - usleep(50000) -- wait a little - plflush() -- force an update of the tk driver - plpoin(1, x+i, y+i,9) -- erase point - } - plxormod(0, &st) -- leave xor mode - } -#else - printf("The -xor command line option can only be exercised if your " - "system\nhas usleep(), which does not seem to happen.\n") -#endif - } -} - - -- =============================================================== - -void -plot2(void) -{ - int i - --- Set up the viewport and window using PLENV. The range in X is -2.0 to - * 10.0, and the range in Y is -0.4 to 2.0. The axes are scaled separately - * (just = 0), and we draw a box with axes (axis = 1). - - plcol0(1) - plenv(-2.0, 10.0, -0.4, 1.2, 0, 1) - plcol0(2) - pllab("(x)", "sin(x)/x", "#frPLplot Example 1 - Sinc Function") - --- Fill up the arrays - - for (i = 0 i < 100 i++) { - x[i] = (i - 19.0) / 6.0 - y[i] = 1.0 - if (x[i] != 0.0) - y[i] = sin(x[i]) / x[i] - } - --- Draw the line - - plcol0(3) - plwid(2) - plline(100, x, y) - plwid(1) -} - - -- =============================================================== - -void -plot3(void) -{ - PLINT space0 = 0, mark0 = 0, space1 = 1500, mark1 = 1500 - int i - --- For the final graph we wish to override the default tick intervals, and - * so do not use plenv(). - - pladv(0) - --- Use standard viewport, and define X range from 0 to 360 degrees, Y range - * from -1.2 to 1.2. - - plvsta() - plwind(0.0, 360.0, -1.2, 1.2) - --- Draw a box with ticks spaced 60 degrees apart in X, and 0.2 in Y. - - plcol0(1) - plbox("bcnst", 60.0, 2, "bcnstv", 0.2, 2) - --- Superimpose a dashed line grid, with 1.5 mm marks and spaces. - * plstyl expects a pointer! - - plstyl(1, &mark1, &space1) - plcol0(2) - plbox("g", 30.0, 0, "g", 0.2, 0) - plstyl(0, &mark0, &space0) - - plcol0(3) - pllab("Angle (degrees)", "sine", "#frPLplot Example 1 - Sine function") - - for (i = 0 i < 101 i++) { - x[i] = 3.6 * i - y[i] = sin(x[i] * M_PI / 180.0) - } - - plcol0(4) - plline(101, x, y) -} +pl.plend() Modified: trunk/examples/lua/x08.lua =================================================================== --- trunk/examples/lua/x08.lua 2009-01-27 08:21:33 UTC (rev 9406) +++ trunk/examples/lua/x08.lua 2009-01-27 08:37:04 UTC (rev 9407) @@ -55,7 +55,7 @@ end pl.scmap1n(256) - pl.scmap1l(0, i, h, l, s, {0} ) + pl.scmap1l(0, i, h, l, s, { 0 } ) -- TODO: last table should actually be empty end ---------------------------------------------------------------------------- Added: trunk/examples/lua/x15.lua =================================================================== --- trunk/examples/lua/x15.lua (rev 0) +++ trunk/examples/lua/x15.lua 2009-01-27 08:37:04 UTC (rev 9407) @@ -0,0 +1,281 @@ +-- $Id$ + +-- Shade plot demo. + +-- initialise Lua bindings to PLplot +if string.sub(_VERSION,1,7)=='Lua 5.0' then + lib=loadlib('./plplotluac.so','luaopen_plplotluac') or loadlib('plplotluac.dll','luaopen_plplotluac') + assert(lib)() +else + require('plplotluac') +end + + +XPTS = 35 -- Data points in x +YPTS = 46 -- Data points in y + +z = {} + +-- Function prototypes + +----------------------------------------------------------------------------*\ + * cmap1_init1 + * + * Initializes color map 1 in HLS space. +\*-------------------------------------------------------------------------- + +static void +cmap1_init1(void) +{ + PLFLT i[4], h[4], l[4], s[4] + + i[0] = 0 -- left boundary + i[1] = 0.45 -- just before center + i[2] = 0.55 -- just after center + i[3] = 1 -- right boundary + + h[0] = 260 -- hue -- low: blue-violet + h[1] = 260 -- only change as we go over vertex + h[2] = 20 -- hue -- high: red + h[3] = 20 -- keep fixed + +#if 1 + l[0] = 0.5 -- lightness -- low + l[1] = 0.0 -- lightness -- center + l[2] = 0.0 -- lightness -- center + l[3] = 0.5 -- lightness -- high +#else + plscolbg(255,255,255) + l[0] = 0.5 -- lightness -- low + l[1] = 1.0 -- lightness -- center + l[2] = 1.0 -- lightness -- center + l[3] = 0.5 -- lightness -- high +#endif + s[0] = 1 -- maximum saturation + s[1] = 1 -- maximum saturation + s[2] = 1 -- maximum saturation + s[3] = 1 -- maximum saturation + + c_plscmap1l(0, 4, i, h, l, s, NULL) +} + +----------------------------------------------------------------------------*\ + * cmap1_init2 + * + * Initializes color map 1 in HLS space. +\*-------------------------------------------------------------------------- + +static void +cmap1_init2(void) +{ + PLFLT i[4], h[4], l[4], s[4] + + i[0] = 0 -- left boundary + i[1] = 0.45 -- just before center + i[2] = 0.55 -- just after center + i[3] = 1 -- right boundary + + h[0] = 260 -- hue -- low: blue-violet + h[1] = 260 -- only change as we go over vertex + h[2] = 20 -- hue -- high: red + h[3] = 20 -- keep fixed + +#if 1 + l[0] = 0.6 -- lightness -- low + l[1] = 0.0 -- lightness -- center + l[2] = 0.0 -- lightness -- center + l[3] = 0.6 -- lightness -- high +#else + plscolbg(255,255,255) + l[0] = 0.5 -- lightness -- low + l[1] = 1.0 -- lightness -- center + l[2] = 1.0 -- lightness -- center + l[3] = 0.5 -- lightness -- high +#endif + s[0] = 1 -- saturation -- low + s[1] = 0.5 -- saturation -- center + s[2] = 0.5 -- saturation -- center + s[3] = 1 -- saturation -- high + + c_plscmap1l(0, 4, i, h, l, s, NULL) +} + +----------------------------------------------------------------------------*\ + * plot1 + * + * Illustrates a single shaded region. +\*-------------------------------------------------------------------------- + +static void +plot1(void) +{ + PLFLT shade_min, shade_max, sh_color + PLINT sh_cmap = 0, sh_width + PLINT min_color = 0, min_width = 0, max_color = 0, max_width = 0 + + pladv(0) + plvpor(0.1, 0.9, 0.1, 0.9) + plwind(-1, 1, -1, 1.0) + +-- Plot using identity transform + + shade_min = zmin + (zmax-zmin)*0.4 + shade_max = zmin + (zmax-zmin)*0.6 + sh_color = 7 + sh_width = 2 + min_color = 9 + max_color = 2 + min_width = 2 + max_width = 2 + + plpsty(8) + plshade1(&z[0][0], XPTS, YPTS, NULL, -1., 1., -1., 1., + shade_min, shade_max, + sh_cmap, sh_color, sh_width, + min_color, min_width, max_color, max_width, + plfill, 1, NULL, NULL) + + plcol0(1) + plbox("bcnst", 0, 0, "bcnstv", 0, 0) + plcol0(2) + pllab("distance", "altitude", "Bogon flux") +} + +----------------------------------------------------------------------------*\ + * plot2 + * + * Illustrates multiple adjacent shaded regions, using different fill + * patterns for each region. +\*-------------------------------------------------------------------------- + +static void +plot2(void) +{ + PLFLT shade_min, shade_max, sh_color + PLINT sh_cmap = 0, sh_width + PLINT min_color = 0, min_width = 0, max_color = 0, max_width = 0 + int i + static PLINT nlin[10] = {1, 1, 1, 1, 1, 2, 2, 2, 2, 2} + static PLINT inc[10][2] = { {450, 0}, {-450, 0}, {0, 0}, {900, 0}, + {300, 0}, {450,-450}, {0, 900}, {0, 450}, + {450, -450}, {0, 900} } + static PLINT del[10][2] = { {2000, 2000}, {2000, 2000}, {2000, 2000}, + {2000, 2000}, {2000, 2000}, {2000, 2000}, + {2000, 2000}, {2000, 2000}, {4000, 4000}, + {4000, 2000} } + + sh_width = 2 + + pladv(0) + plvpor(0.1, 0.9, 0.1, 0.9) + plwind(-1, 1, -1, 1.0) + +-- Plot using identity transform + + for (i = 0 i < 10 i++) { + shade_min = zmin + (zmax - zmin) * i / 10.0 + shade_max = zmin + (zmax - zmin) * (i +1) / 10.0 + sh_color = i+6 + plpat(nlin[i],inc[i],del[i]) + + plshade1(&z[0][0], XPTS, YPTS, NULL, -1., 1., -1., 1., + shade_min, shade_max, + sh_cmap, sh_color, sh_width, + min_color, min_width, max_color, max_width, + plfill, 1, NULL, NULL) + } + + plcol0(1) + plbox("bcnst", 0, 0, "bcnstv", 0, 0) + plcol0(2) + pllab("distance", "altitude", "Bogon flux") +} + +---------------------------------------------------------------------------- +-- plot3 +-- +-- Illustrates shaded regions in 3d, using a different fill pattern for +-- each region. +---------------------------------------------------------------------------- + +function plot3() + xx = { {-1, 1, 1, -1, -1}, {-1, 1, 1, -1, -1} } + yy = { {1, 1, 0, 0, 1}, {-1, -1, 0, 0, -1} } + zz = { {0, 0, 1, 1, 0}, {0, 0, 1, 1, 0} } + + pl.adv(0) + pl.vpor(0.1, 0.9, 0.1, 0.9) + pl.wind(-1, 1, -1, 1.) + pl.w3d(1., 1., 1., -1, 1, -1, 1, 0, 1.5, 30, -40) + + -- Plot using identity transform + pl.col0(1) + pl.box3("bntu", "X", 0, 0, "bntu", "Y", 0, 0, "bcdfntu", "Z", 0.5, 0) + pl.col0(2) + pl.lab("","","3-d polygon filling") + + pl.col0(3) + pl.psty(1) + pl.line3(xx[1], yy[1], zz[1]) + pl.fill3(xx[1], yy[1], zz[1]) + pl.psty(2) + pl.line3(xx[2], yy[2], zz[2]) + pl.fill3(xx[2], yy[2], zz[2]) +end + +---------------------------------------------------------------------------- +-- f2mnmx +-- +-- Returns min & max of input 2d array. +---------------------------------------------------------------------------- + +function F(a,b) (f[a*ny+b]) + +function f2mnmx(PLFLT *f, PLINT nx, PLINT ny, PLFLT *fmin, PLFLT *fmax) + fmax = f[0] + fmin = fmax + + for i = 1, nx do + for j = 1,ny do + fmax = MAX(*fmax, F(i, j)) + fmin = MIN(*fmin, F(i, j)) + end + end +end + + +---------------------------------------------------------------------------- +-- main +-- +-- Does a variety of shade plots. +---------------------------------------------------------------------------- + +-- Parse and process command line arguments +pl.parseopts(arg, pl.PL_PARSE_FULL) + +-- Set up color map 0 +pl.scmap0n(3) + +-- Set up color map 1 +cmap1_init2() + +-- Initialize plplot +pl.init() + +-- Set up data array +for i=1, XPTS do + xx = ((i-1) - math.floor(XPTS/2)) / math.floor(XPTS/2) + z[i] = {} + for j=1, YPTS do + yy = ((j-1) - math.floor(YPTS/2)) / math.floor(YPTS/2) - 1 + + z[i][j] = xx*xx - yy*yy + (xx - yy)/(xx*xx+yy*yy + 0.1) + end +end +zmin, zmax = f2mnmx(z, XPTS, YPTS) + +plot1() +plot2() +plot3() + +pl.plend() Property changes on: trunk/examples/lua/x15.lua ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/examples/lua/x18.lua =================================================================== --- trunk/examples/lua/x18.lua (rev 0) +++ trunk/examples/lua/x18.lua 2009-01-27 08:37:04 UTC (rev 9407) @@ -0,0 +1,133 @@ +-- $Id$ + +-- 3-d line and point plot demo. Adapted from x08c.c. + + +-- initialise Lua bindings to PLplot +if string.sub(_VERSION,1,7)=='Lua 5.0' then + lib=loadlib('./plplotluac.so','luaopen_plplotluac') or loadlib('plplotluac.dll','luaopen_plplotluac') + assert(lib)() +else + require('plplotluac') +end + + +function test_poly(k) + draw= { { 1, 1, 1, 1 }, + { 1, 0, 1, 0 }, + { 0, 1, 0, 1 }, + { 1, 1, 0, 0 } } + + x = {} + y = {} + z = {} + + pl.adv(0) + pl.vpor(0, 1, 0, 0.9) + pl.wind(-1, 1, -0.9, 1.1) + pl.col0(1) + pl.w3d(1, 1, 1, -1, 1, -1, 1, -1, 1, alt[k], az[k]) + pl.box3("bnstu", "x axis", 0.0, 0, + "bnstu", "y axis", 0.0, 0, + "bcdmnstuv", "z axis", 0.0, 0) + + pl.col0(2) + + -- x = r math.sin(phi) math.cos(theta) + -- y = r math.sin(phi) math.sin(theta) + -- z = r math.cos(phi) + -- r = 1 :=) + + for i=0, 19 do + for j=0, 19 do + x[0] = math.sin( math.pi*j/20.1 ) * math.cos( 2*math.pi*i/20 ) + y[0] = math.sin( math.pi*j/20.1 ) * math.sin( 2*math.pi*i/20 ) + z[0] = math.cos( math.pi*j/20.1 ) + + x[1] = math.sin( math.pi*(j+1)/20.1 ) * math.cos( 2*math.pi*i/20 ) + y[1] = math.sin( math.pi*(j+1)/20.1 ) * math.sin( 2*math.pi*i/20 ) + z[1] = math.cos( math.pi*(j+1)/20.1 ) + + x[2] = math.sin( math.pi*(j+1)/20.1 ) * math.cos( 2*math.pi*(i+1)/20 ) + y[2] = math.sin( math.pi*(j+1)/20.1 ) * math.sin( 2*math.pi*(i+1)/20 ) + z[2] = math.cos( math.pi*(j+1)/20.1 ) + + x[3] = math.sin( math.pi*j/20.1 ) * math.cos( 2*math.pi*(i+1)/20 ) + y[3] = math.sin( math.pi*j/20.1 ) * math.sin( 2*math.pi*(i+1)/20 ) + z[3] = math.cos( math.pi*j/20.1 ) + + x[4] = math.sin( math.pi*j/20.1 ) * math.cos( 2*math.pi*i/20 ) + y[4] = math.sin( math.pi*j/20.1 ) * math.sin( 2*math.pi*i/20 ) + z[4] = math.cos( math.pi*j/20.1 ) + + pl.poly3( x, y, z, draw[k], 1 ) + end + end + + pl.col0(3) + pl.mtex("t", 1, 0.5, 0.5, "unit radius sphere" ) +end + + +---------------------------------------------------------------------------- +-- main +-- +-- Does a series of 3-d plots for a given data set, with different +-- viewing options in each plot. +---------------------------------------------------------------------------- + +NPTS = 1000 +opt = { 1, 0, 1, 0 } +alt = { 20, 35, 50, 65 } +az = { 30, 40, 50, 60 } + + +-- Parse and process command line arguments +pl.parseopts(arg, pl.PL_PARSE_FULL) + +-- Initialize plplot +pl.init() + +for k=1, 4 do + test_poly(k) +end + +x = {} +y = {} +z = {} + +-- From the mind of a sick and twisted physicist... +for i=1, NPTS do + z[i] = -1 + 2 * (i-1) / NPTS + + -- Pick one ... + -- r = 1 - (i-1) / NPTS + r = z[i] + + x[i] = r * math.cos( 2 * math.pi * 6 * (i-1) / NPTS ) + y[i] = r * math.sin( 2 * math.pi * 6 * (i-1) / NPTS ) +end + +for k=1, 4 do + pl.adv(0) + pl.vpor(0, 1, 0, 0.9) + pl.wind(-1, 1, -0.9, 1.1) + pl.col0(1) + pl.w3d(1, 1, 1, -1, 1, -1, 1, -1, 1, alt[k], az[k]) + pl.box3("bnstu", "x axis", 0, 0, + "bnstu", "y axis", 0, 0, + "bcdmnstuv", "z axis", 0, 0) + + pl.col0(2) + + if opt[k]~=0 then + pl.line3( x, y, z ) + else + pl.poin3( x, y, z, 1 ) + end + + pl.col0(3) + pl.mtex("t", 1.0, 0.5, 0.5, "#frPLplot Example 18 - Alt=" .. alt[k] .. ", Az=" .. az[k]) +end + +pl.plend() Property changes on: trunk/examples/lua/x18.lua ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/examples/lua/x22.lua =================================================================== --- trunk/examples/lua/x22.lua 2009-01-27 08:21:33 UTC (rev 9406) +++ trunk/examples/lua/x22.lua 2009-01-27 08:37:04 UTC (rev 9407) @@ -1,4 +1,4 @@ ---[[ $Id: x22c.c 8033 2007-11-23 15:28:09Z andrewross $ +--[[ $Id$ Simple vector plot example Copyright (C) 2004 Andrew Ross <and...@us...> Property changes on: trunk/examples/lua/x22.lua ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |