11:15:39 AM Nov 06
#!/usr/bin/env lua
local Gnuplot = { }
function Gnuplot:init()
.gp = io.popen("gnuplot", "w")
selfend
function Gnuplot:write(cmd)
.gp:write(cmd, "\n")
self.gp:flush()
selfend
function Gnuplot:close()
.gp:close()
selfend
return Gnuplot
#!/usr/bin/env lua
= os.getenv("HOME")
home package.path = string.format("%s/Dropbox/codes/Gnuplot.lua/Gnuplot.lua", home)
= require "Gnuplot"
gp
-- Start Gnuplot...
:init()
gp
-- Gnuplot commands...
:write("plot sin(x)")
gp
-- For display purpose
io.write("Press enter to exit...")
io.read()
-- Close Gnuplot...
:close() gp