Root/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()
55

Archive Download this file



interactive