import graph;
+import palette;
real fsize=10;
}
}
+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+"}$";
}