GDT plot minor code improvements - gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/gdt-plot.lua
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2012年12月18日 17:02:43 +0100
committerFrancesco Abbate <francesco.bbt@gmail.com>2012年12月18日 17:02:43 +0100
commitb3ccaabe380cdbca71ff10456b7ed69317d252ef (patch)
tree203408721d68b33ec9b23e7e9f9709ad0d453af8 /gdt-plot.lua
parentc912cffd0e942d77f998488f7b7746d0aa30f052 (diff)
downloadgsl-shell-b3ccaabe380cdbca71ff10456b7ed69317d252ef.tar.gz
GDT plot minor code improvements
Diffstat (limited to 'gdt-plot.lua')
-rw-r--r--gdt-plot.lua 32
1 files changed, 28 insertions, 4 deletions
diff --git a/gdt-plot.lua b/gdt-plot.lua
index 8d624474..5f088a81 100644
--- a/gdt-plot.lua
+++ b/gdt-plot.lua
@@ -42,11 +42,32 @@ local function collate_factors(t, i, js)
return c
end
-local function rect_bin(t, jxs, jys, jes)
- jys = treat_column_refs(t, jys)
+local function vec2d_get(r, i, j)
+ if r[i] and r[i][j] then
+ return r[i][j]
+ end
+end
+
+local function vec2d_set(r, i, j, v)
+ if not r[i] then r[i] = {} end
+ r[i][j] = v
+end
+
+local function vec2d_incr(r, i, j)
+ if not r[i] then r[i] = {} end
+ local v = r[i][j] or 0
+ r[i][j] = v + 1
+ return v + 1
+end
+
+local function treat_all_column_refs(t, jxs, jys, jes)
jxs = treat_column_refs(t, jxs)
+ jys = treat_column_refs(t, jys)
jes = treat_column_refs(t, jes)
+ return jxs, jys, jes
+end
+local function rect_bin(t, jxs, jys, jes)
local n = #t
local val = {}
local enums, labels = {}, {}
@@ -59,8 +80,7 @@ local function rect_bin(t, jxs, jys, jes)
end
local ie = add_unique(enums, e)
local ix = add_unique(labels, c)
- if not val[ix] then val[ix] = {} end
- val[ix][ie] = t:get(i, jys[p])
+ vec2d_set(val, ix, ie, t:get(i, jys[p]))
end
end
@@ -68,6 +88,8 @@ local function rect_bin(t, jxs, jys, jes)
end
local function gdt_table_barplot(t, jxs, jys, jes)
+ jxs, jys, jes = treat_all_column_refs(t, jxs, jys, jes)
+
local rect, webcolor = graph.rect, graph.webcolor
local labels, enums, val = rect_bin(t, jxs, jys, jes)
@@ -121,6 +143,8 @@ local function add_legend(lg, k, symspec, color, text)
end
local function gdt_table_lineplot(t, jxs, jys, jes)
+ jxs, jys, jes = treat_all_column_refs(t, jxs, jys, jes)
+
local path, webcolor = graph.path, graph.webcolor
local labels, enums, val = rect_bin(t, jxs, jys, jes)
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月15日 20:02:26 +0000

AltStyle によって変換されたページ (->オリジナル) /