-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.lua
More file actions
54 lines (45 loc) · 1.44 KB
/
example.lua
File metadata and controls
54 lines (45 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#! /usr/bin/env lua
local gp = require('gnuplot')
-- gp.bin = '/usr/local/bin/mygnuplot'
local g = gp{
-- all optional, with sane defaults
width = 640,
height = 480,
xlabel = "X axis",
ylabel = "Y axis",
key = "top left",
consts = {
gamma = 2.5
},
data = {
gp.file { -- plot from a file
"myfile", -- file path
title = "Title 1", -- optional
},
gp.array { -- plot from an 'array-like' thing in memory. Could be a
-- numlua matrix, for example.
{
{0,1,2,3,4,5,6,7,8,9}, -- x
{3,4,5,6,7,8,9,8,7,6} -- y
},
title = "Title 2", -- optional
using = {1,2}, -- optional
with = 'linespoints' -- optional
},
gp.func { -- plot from a Lua function
function(x) -- function to plot
return 3* math.sin(2*x) + 4
end,
range = {-2, 10, 0.01}, -- optional
width = 3, -- optional
},
gp.gpfunc { -- plot from a native gnuplot function
"gamma*sin(1.8*x) + 3",
width = 2,
},
}
}:plot('output.png')
-- plot with other terminals
--g:plot('output.svg')
--g:plot('output.pdf')
--g:plot('output.wxt')