This only works with MathJax inline SVG and Console output at the moment.

using the gnuplot syntax:

local symmath = require 'symmath'
local GnuPlot = symmath.export.GnuPlot
GnuPlot:plot{
	title = 'test plot',
	xrange = {-2,2},
	{'x**2.', title='test plot "x**2."'},
	{'x**3.', title='test plot "x**3."'},
}
Gnuplot Produced by GNUPLOT 6.0 patchlevel 0 -8 -6 -4 -2 0 2 4 6 8 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 test plot "x**2." test plot "x**2." test plot "x**3." test plot "x**3." test plot

using symmath expressions:

local symmath = require 'symmath'
local GnuPlot = symmath.export.GnuPlot
local x = symmath.var'x'
GnuPlot:plot{
	title = 'test expression',
	xrange = {-2,2},
	{x^2, title=GnuPlot(x^2)},
	{x^3, title=GnuPlot(x^3)},
}
Gnuplot Produced by GNUPLOT 6.0 patchlevel 0 -8 -6 -4 -2 0 2 4 6 8 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 ((x) ** (2.)) ((x) ** (2.)) ((x) ** (3.)) ((x) ** (3.)) test expression

using plot member function:

local symmath = require 'symmath'
local x = symmath.var'x'
-- unless it's assigned to another var, or an argument of a function call, math operators will screw up Lua grammar so a subsequent member call is ignored
-- to get around this I'm wrapping the call in print()
-- but take note: (x^2):plot(...) will cause a Lua error
print((x^2):plot{
	title = 'test expression',
	xrange = {-2,2},
	{title=GnuPlot(x^2)},	-- the first table is assumed to be associated with the calling expression
})
Gnuplot Produced by GNUPLOT 6.0 patchlevel 0 0 0.5 1 1.5 2 2.5 3 3.5 4 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 ((x) ** (2.)) ((x) ** (2.)) test expression

using Lua data for formula:

local symmath = require 'symmath'
local GnuPlot = symmath.export.GnuPlot
local n = 50
local xmin, xmax = -10, 10
local xs, ys = {}, {}
for i=1,n do
	local x = (i-.5)/n * (xmax - xmin) + xmin
	xs[i] = x
	ys[i] = math.sin(x) / x
end
GnuPlot:plot{
	title = 'test data title',
	style = 'data linespoints',
	data = {xs, ys},
	{using = '1:2', title = 'test data sin(x)/x'},
}
Gnuplot Produced by GNUPLOT 6.0 patchlevel 0 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 -10 -8 -6 -4 -2 0 2 4 6 8 10 test data sin(x)/x test data sin(x)/x test data title

using symmath expressions, code generation, and Lua data:

local symmath = require 'symmath'
local GnuPlot = symmath.export.GnuPlot

local x = symmath.var'x'
local f = symmath.sin(x) / x
local ff = symmath.export.Lua:toFunc{input={x}, output={f}}
local n = 50
local xmin, xmax = -10, 10
local xs, ys = {}, {}
for i=1,n do
	local x = (i-.5)/n * (xmax - xmin) + xmin
	xs[i] = x
	ys[i] = ff(x)
end
GnuPlot:plot{
	title = 'test data title',
	style = 'data linespoints',
	data = {xs, ys},
	{using = '1:2', title = 'test data '..export.GnuPlot(f)},
}
Gnuplot Produced by GNUPLOT 6.0 patchlevel 0 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 -10 -8 -6 -4 -2 0 2 4 6 8 10 test data sin(x) / x test data sin(x) / x test data title

using the gnuplot syntax:

local symmath = require 'symmath'
local GnuPlot = symmath.export.GnuPlot
print'
'
GnuPlot:plot{
	outputType = 'Console',
	title = 'test plot',
	xrange = {-2,2},
	{'x**2.', title='test plot "x**2."'},
	{'x**3.', title='test plot "x**3."'},
}
print'
'
                                                                               
                                                                               
                                   test plot                                   
  8 +----------------------------------------------------------------------+   
    |        +        +        +        +       +        +        +       #|   
  6 |-+                                          test plot "x**2." ****###-|   
    |                                            test plot "x**3." ####### |   
  4 |-+                                                             ##   +-|   
    |****                                                         ##   ****|   
    |   ******                                                 ###******   |   
  2 |-+      ******                                        ####****      +-|   
    |              **********                      **#######*              |   
  0 |-+                   ############################                   +-|   
    |               #######                                                |   
 -2 |-+          ####                                                    +-|   
    |         ###                                                          |   
 -4 |-+     ##                                                           +-|   
    |     ##                                                               |   
    |   ##                                                                 |   
 -6 |-###                                                                +-|   
    |#       +        +        +        +       +        +        +        |   
 -8 +----------------------------------------------------------------------+   
   -2      -1.5      -1      -0.5       0      0.5       1       1.5       2