OpenWrt packages
Sign in or create your account | Project List | Help
OpenWrt packages Git Source Tree
Root/
| 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. |
| 25 | dofile("plplot_examples.lua") |
| 26 | |
| 27 | function 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); |
| 35 | end |
| 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 | |
| 44 | y0 = {} |
| 45 | |
| 46 | pos = { 0, 0.25, 0.5, 0.75, 1 } |
| 47 | red = { 0, 0.25, 0.5, 1, 1 } |
| 48 | green = { 1, 0.5, 0.5, 0.5, 1 } |
| 49 | blue = { 1, 1, 0.5, 0.25, 0 } |
| 50 | |
| 51 | |
| 52 | -- Parse and process command line arguments |
| 53 | |
| 54 | pl.parseopts(arg, pl.PL_PARSE_FULL); |
| 55 | |
| 56 | -- Initialize plplot |
| 57 | pl.init() |
| 58 | |
| 59 | pl.adv(0) |
| 60 | pl.vsta() |
| 61 | pl.wind(1980, 1990, 0, 35) |
| 62 | pl.box("bc", 1, 0, "bcnv", 10, 0) |
| 63 | pl.col0(2) |
| 64 | pl.lab("Year", "Widget Sales (millions)", "#frPLplot Example 12") |
| 65 | |
| 66 | y0 = { 5, 15, 12, 24, 28, 30, 20, 8, 12, 3} |
| 67 | |
| 68 | pl.scmap1l(1, pos, red, green, blue); |
| 69 | |
| 70 | for 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)); |
| 76 | end |
| 77 | |
| 78 | pl.plend(); |
| 79 |
