lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Fri, Oct 22, 2010 at 6:18 PM, Hakki Dogusan <dogusanh@tr.net> wrote:
>> well, there's http://oproj.tuxfamily.org/wiki/doku.php?id=luaplot ,
>> but it needs cairo for the drawing.
>
> Nice work!

I agree, nicely done, attractive output.  Straightforward API:

[[
require('luaplot.dotlineplot')
require('luaplot.pnghandler')

-- Example of dot line plot.
local plot = luaplot.dotlineplot.new{
	data            = { {0, 2, 4, 3, -1}, {3, 5, 1, -4, -2} },
	top_bound       = 6,
	bottom_bound    = -6,
	h_labels        = {'2000', '2001', '2002', '2003', '2004'},
	v_labels        = luaplot.generatelabels(-6, 6, 2),
	series_colors   = { {1,0.3,0.3}, {0.3,1,0.3} },
	label_size      = 12,
	handler         = luaplot.pnghandler.new('out-dotlineplot.png'),
}

plot.bg_pattern = cairo.Pattern.create_linear(0, 0, plot.width, plot.height)
plot.bg_pattern:add_color_stop_rgb(0, 1, 1, 1)
plot.bg_pattern:add_color_stop_rgb(1, 0.9, 0.9, 0.9)

plot:render()
]]

I quote this example to show how the API is fairly specific about
things like axis spacings etc. Yes I know heuristics can give bad
divisions, but one can always override these things. Same if you look
at the legend code - does not seem to work know out of the box where
to put legends. A higher-level approach is to specify the corner of
the plot where the legend should be, and whether it should be outside
or not.

This kind of helpful logic can of course be built on top of LuaPlot.

> You may get it here:
> http://www.dynaset.org/dogusanh/download/luaplot.zip  (17KiB)

That's cool, something new has come out of this discussion.

steve d.