From: W. Trevor King Date: Thu, 29 Apr 2010 21:59:57 +0000 (-0400) Subject: Generalized wtk_graph functions to allow user-controlled x/y/z columns X-Git-Tag: v1.0~393 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=61cad305ba61439f7776401628d9ebdf304ac24d;p=thesis.git Generalized wtk_graph functions to allow user-controlled x/y/z columns --- diff --git a/tex/src/figures/asy/wtk_graph.asy b/tex/src/figures/asy/wtk_graph.asy index 87c3ab9..40dd933 100644 --- a/tex/src/figures/asy/wtk_graph.asy +++ b/tex/src/figures/asy/wtk_graph.asy @@ -13,6 +13,7 @@ Label sLabel(string s, align align=NoAlign, int extra_spaces=0) { } void graphFile(picture pic=currentpicture, string file="datafile", + int xcol=0, int ycol=1, real xscale=1, real yscale=1, pen p=red, path mpath=scale(0.8mm)*unitcircle, markroutine markroutine=marknodes, @@ -23,8 +24,8 @@ void graphFile(picture pic=currentpicture, string file="datafile", file fin=input(file).line(); real[][] a=fin.dimension(0,0); a=transpose(a); - real[] x=a[0]; - real[] y=a[1]; + real[] x=a[xcol]; + real[] y=a[ycol]; if (dots == true) { pline = invisible; mk = marker(mpath, markroutine, p); @@ -75,6 +76,7 @@ real[][] extract_matrix(real[] xs, real[] ys, real[] zs) { } void graphMatrixFile(picture pic=currentpicture, string file="datafile", + int xcol=0, int ycol=1, int zcol=2, real xscale=1, real yscale=1, real[] zfn(real[] z)=identity_zfn, pen[] p=BWRainbow(), Label x_label=null, @@ -87,9 +89,9 @@ void graphMatrixFile(picture pic=currentpicture, string file="datafile", if (a[i].length < 3) a.delete(i); a = transpose(a); - real[] xs = a[0]; - real[] ys = a[1]; - real[] zs = zfn(a[2]); + real[] xs = a[xcol]; + real[] ys = a[ycol]; + real[] zs = zfn(a[zcol]); real[][] z = extract_matrix(xs, ys, zs); pair initial = (xscale*min(xs), yscale*min(ys)); pair final = (xscale*max(xs), yscale*max(ys));