-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot.d
45 lines (41 loc) · 906 Bytes
/
plot.d
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
/* This module is of limited use. It's a thin wrapper over R code.
* It's easier to write the R code to do your plotting directly, given
* all the options you have for plotting. */
module betterr.plot;
import betterr.r;
import std.path, std.stdio;
struct Plot {
string name;
string type;
string main;
string sub;
string xlab;
string ylab;
this(string _name) {
name = _name;
}
this(T)(T x) {
name = x.name;
}
void create(string fn) {
string cmd = `pdf("` ~ setExtension(fn, "pdf") ~ `"); plot(` ~ name;
if (type.length > 0) {
cmd ~= `, type='` ~ type ~ `'`;
}
if (main.length > 0) {
cmd ~= `, main='` ~ main ~ `'`;
}
if (sub.length > 0) {
cmd ~= `, sub='` ~ sub ~ `'`;
}
if (xlab.length > 0) {
cmd ~= `, xlab='` ~ xlab ~ `'`;
}
if (ylab.length > 0) {
cmd ~= `, ylab='` ~ ylab ~ `'`;
}
cmd ~= "); dev.off()";
writeln(cmd);
evalRQ(cmd);
}
}