OpenWrt packages
Sign in or create your account | Project List | Help
OpenWrt packages Git Source Tree
Root/
| 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. |
| 25 | dofile("plplot_examples.lua") |
| 26 | |
| 27 | -------------------------------------------------------------------------- |
| 28 | -- main |
| 29 | -- |
| 30 | -- Draws a histogram from sample data. |
| 31 | -------------------------------------------------------------------------- |
| 32 | |
| 33 | NPTS=2047 |
| 34 | data = {} |
| 35 | |
| 36 | -- Parse and process command line arguments |
| 37 | pl.parseopts(arg, pl.PL_PARSE_FULL); |
| 38 | |
| 39 | -- Initialize plplot |
| 40 | pl.init() |
| 41 | |
| 42 | -- Fill up data points |
| 43 | delta = 2.0*math.pi/NPTS |
| 44 | for i=1, NPTS do |
| 45 | data[i] = math.sin((i-1)*delta) |
| 46 | end |
| 47 | |
| 48 | pl.col0(1) |
| 49 | pl.hist(data, -1.1, 1.1, 44, 0) |
| 50 | pl.col0(2) |
| 51 | pl.lab("#frValue", "#frFrequency", |
| 52 | "#frPLplot Example 5 - Probability function of Oscillator") |
| 53 | |
| 54 | pl.plend() |
| 55 |
