author | Francesco Abbate <francesco.bbt@gmail.com> | 2013年07月30日 16:32:16 +0200 |
---|---|---|
committer | Francesco Abbate <francesco.bbt@gmail.com> | 2013年07月30日 16:32:16 +0200 |
commit | 5096fb045f7d24ca1acac9e62259b28747875a40 (patch) | |
tree | a84e56ed697386940a994ed68836747ce23bf806 /gdt-plot.lua | |
parent | df198e4244ac05ca9dee5bfbc848240553150cf2 (diff) | |
download | gsl-shell-5096fb045f7d24ca1acac9e62259b28747875a40.tar.gz |
-rw-r--r-- | gdt-plot.lua | 31 |
diff --git a/gdt-plot.lua b/gdt-plot.lua index 5a639806..31914271 100644 --- a/gdt-plot.lua +++ b/gdt-plot.lua @@ -349,9 +349,23 @@ local function expr_get_functions(exprs) return jys end +local xyplot_default = { + lines= false, + markers= true, + line_width= 3, + marker_size= 6, + show = true, +} + +local function get_option(opt, default, name) + if not opt or (opt[name] == nil) then + return default[name] + end + return opt[name] +end + local function gdt_table_category_plot(plotter, t, plot_descr, opt) - local show_plot = true - if opt then show_plot = (opt.show ~= false) end + local show_plot = get_option(opt, xyplot_default, "show") local schema = expr_parse.schema_multivar(plot_descr, AST) local jxs = idents_get_column_indexes(t, schema.x) @@ -395,11 +409,12 @@ function gdt.xyline(t, plot_descr) end local function gdt_table_xyplot(t, plot_descr, opt) - local show_plot = true - if opt then show_plot = (opt.show ~= false) end + local show_plot = get_option(opt, xyplot_default, "show") - local use_lines = opt and opt.lines - local use_markers = opt and (opt.markers ~= false) or true + local use_lines = get_option(opt, xyplot_default, "lines") + local use_markers = get_option(opt, xyplot_default, "markers") + local line_width = get_option(opt, xyplot_default, "line_width") + local marker_size = get_option(opt, xyplot_default, "marker_size") local schema = expr_parse.schema_multivar(plot_descr, AST) local jxs = expr_get_functions(schema.x) @@ -451,10 +466,10 @@ local function gdt_table_xyplot(t, plot_descr, opt) end if use_lines then - plt:add(ln, webcolor(iq), {{'stroke', width=3}}) + plt:add(ln, webcolor(iq), {{'stroke', width=line_width}}) end if use_markers then - plt:add(ln, webcolor(iq), {{'marker', size=6, mark=iq}}) + plt:add(ln, webcolor(iq), {{'marker', size=marker_size, mark=iq}}) end end end |