-
Notifications
You must be signed in to change notification settings - Fork 0
/
datagraphs.asy
68 lines (52 loc) · 1.39 KB
/
datagraphs.asy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import graph;
import utils;
//asy datagraphs -u "xlabel=\"\$\\bm{u}\cdot\\bm{B}/uB$\"" -u "doyticks=false" -u "ylabel=\"\"" -u "legendlist=\"a,b\""
texpreamble("\usepackage{bm}");
size(200,150,IgnoreAspect);
//scale(Linear,Linear);
scale(Log,Linear);
bool dolegend=true;
string filenames=getstring("filenames");
string filename;
string legendlist="";
int n=-1;
bool flag=true;
int lastpos;
bool doxticks=true;
bool doyticks=true;
string xlabel="$x$";
string ylabel="$y$";
usersetting();
bool myleg=((legendlist == "") ? false: true);
string[] legends=set_legends(legendlist);
bool errorbars = false;
while(flag) {
++n;
int pos = find(filenames,",",lastpos);
if(lastpos == -1) {filename = ""; flag = false;}
filename = substr(filenames,lastpos,pos-lastpos);
if(flag) {
lastpos = pos > 0 ? pos+1 : -1;
file fin = input(filename).line();
real[][] a = fin.dimension(0,0);
a = transpose(a);
real[] x = a[0];
real[] y = a[1];
int N = a.length - 1;
for(int i = 0; i < N; ++i) {
pen p = Pen(i);
if(i == 1) p += dashed;
if(i == 2) p = darkgreen + Dotted;
draw(graph(x, a[i+1]), p, myleg ? legends[n] : texify(filename));
}
}
}
if(doxticks)
xaxis(xlabel,BottomTop,LeftTicks);
else
xaxis(xlabel);
if(doyticks)
yaxis(ylabel,LeftRight,RightTicks);
else
yaxis(ylabel,LeftRight);
//if(dolegend) attach(legend(),point(plain.E),20plain.E);