From: W. Trevor King Date: Wed, 28 Apr 2010 12:02:18 +0000 (-0400) Subject: Added untested graphMatrixFile to wtk_graph.asy X-Git-Tag: v1.0~408 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=674952f2c5a6266b7efc4a21de17becf69751443;p=thesis.git Added untested graphMatrixFile to wtk_graph.asy --- diff --git a/tex/src/figures/asy/wtk_graph.asy b/tex/src/figures/asy/wtk_graph.asy index 80fccb7..1e8b172 100644 --- a/tex/src/figures/asy/wtk_graph.asy +++ b/tex/src/figures/asy/wtk_graph.asy @@ -1,4 +1,5 @@ import graph; +import palette; real fsize=10; @@ -35,6 +36,34 @@ void graphFile(picture pic=currentpicture, string file="datafile", } } +real[] identity_zfn(real[] z) { + return z; +} + +void graphMatrixFile(picture pic=currentpicture, string file="datafile", + real xscale=1, real yscale=1, + real[] zfn(real[] z)=identity_zfn, + pen[] p=BWRainbow(), Label palette_label=null) { + file fin = input(file).line(); + real[][] a = fin.dimension(0,0); + /* drop blank lines used to separate Gnuplot blocks. */ + for (int i=a.length-1; i >= 0; --i) + if (a[i].length < 3) + a.delete(i); + a = transpose(a); + real[] x = a[0]; + real[] y = a[1]; + real[] z = a[2]; //zfn(a[2]); + bounds range = image(pic=pic, x=xscale*x, y=yscale*y, f=z, palette=p); + pair initial = point(SE) + (0,6pt); + pair final = point(NE) + (0,6pt); + if (palette_label == null) + palette(pic=pic, bounds=range, initial=initial, final=final, palette=p); + else + palette(pic=pic, L=palette_label, bounds=range, initial=initial, + final=final, palette=p); +} + string units(string value, string units) { return "$"+value+"\mbox{ "+units+"}$"; }