writeMultiCsv

csv dumping for gnuplot controller structure (many columns)

int
writeMultiCsv
(
RoR
)
(
string fileName
,,
string title
)

Examples

auto gpc = start; 
assert(gpc.gnucmd.stdin.isOpen); 
gpc.finish; 
    import std.stdio : writeln; 
	auto gpc = gnuplotd.start; 
	assert(gpc.pstyle == "points");
	assert(gpc.gnucmd.stdin.isOpen); 
    gpc.put("set terminal gif animate"); // delay 100 (= 1 sec)
    gpc.put("set terminal gif animate");
    gpc.put("set output \"./tests/anim1.gif\"");
	double phase;
	
    writeln("*** example of gnuplot control through D ***");
    /*

    set terminal gif animate delay 100
    set output 'foobar.gif'
    stats 'datafile' nooutput
    set xrange [-0.5:1.5]
    set yrange [-0.5:5.5]

    do for [i=1:int(STATS_blocks)] {
        plot 'datafile' index (i-1) with circles
    }
    
    */
    for (phase = 0.1; phase < 10; phase += 0.1)
    {
        gpc.put("plot sin(x+%g)", phase);
    }
    
    for (phase = 10; phase >= 0.1; phase -= 0.1)
    {
        gpc.put("plot sin(x+%g)", phase);
    }
    gpc.finish; 
1     import std.stdio : writeln; 
2 	import core.thread : Thread; 
3 	import core.time : dur; 
4 	enum SLEEP_LGTH = dur!("seconds")(2); 
5 	enum NPOINTS = 50; 
6 	auto gpc1 = start; 
7 	auto gpc2 = start; 
8 	auto gpc3 = start; 
9 	auto gpc4 = start; 
10 
11 	double[NPOINTS] x;
12     double[NPOINTS] y;
13     int i;
14 
15     /*
16      * Initialize the gnuplot handle
17      */
18     writeln("*** example of gnuplot control through D ***");
19 
20     /*
21      * Slopes
22      */
23     gpc1.setStyle("lines") ;
24     
25     writeln("*** plotting slopes");
26     writeln("y = x");
27     gpc1.plotSlope(1.0, 0.0, "unity slope") ;
28     Thread.sleep(SLEEP_LGTH) ;
29 
30     writeln("y = 2*x") ;
31     gpc1.plotSlope(2.0, 0.0, "y=2x") ;
32     Thread.sleep(SLEEP_LGTH) ;
33 
34     writeln("y = -x") ;
35     gpc1.plotSlope(-1.0, 0.0, "y=-x") ;
36     Thread.sleep(SLEEP_LGTH) ;
37 
38     
39     /*
40      * Equations
41      */
42     gpc1.resetPlot;
43     writeln();
44     writeln();
45     writeln("*** various equations");
46     writeln("y = sin(x)");
47     gpc1.plotEquation("sin(x)", "sine");
48     Thread.sleep(SLEEP_LGTH);
49 
50     writeln("y = log(x)");
51     gpc1.plotEquation("log(x)", "logarithm");
52     Thread.sleep(SLEEP_LGTH) ;
53 
54     writeln("y = sin(x)*cos(2*x)");
55     gpc1.plotEquation("sin(x)*cos(2*x)", "sine product");
56     Thread.sleep(SLEEP_LGTH) ;
57 
58 
59     /*
60      * Styles
61      */
62     gpc1.resetPlot;
63     writeln(); 
64     writeln();
65 
66     writeln("*** showing styles");
67 
68     writeln("sine in points");
69     gpc1.setStyle("points");
70     gpc1.plotEquation("sin(x)", "sine");
71     Thread.sleep(SLEEP_LGTH) ;
72     
73     writeln("sine in impulses") ;
74     gpc1.setStyle("impulses");
75     gpc1.plotEquation("sin(x)", "sine");
76     Thread.sleep(SLEEP_LGTH) ;
77     
78     writeln("sine in steps");
79     gpc1.setStyle("steps");
80     gpc1.plotEquation("sin(x)", "sine");
81     Thread.sleep(SLEEP_LGTH) ;
82 
83     /*
84      * User defined 1d and 2d point sets
85      */
86     gpc1.resetPlot;
87     gpc1.setStyle("impulses");
88     writeln(); 
89     writeln(); 
90 
91     writeln("*** user-defined lists of doubles");
92     for (i=0 ; i<NPOINTS ; i++) {
93         x[i] = cast(double)i*i ;
94     }
95     gpc1.plotX(x, "user-defined doubles");
96     Thread.sleep(SLEEP_LGTH) ;
97 
98 	writeln("*** user-defined lists of points");
99     for (i=0 ; i<NPOINTS ; i++) {
100         x[i] = cast(double)i ;
101         y[i] = cast(double)i * cast(double)i ;
102     }
103     gpc1.resetPlot;
104     gpc1.setStyle("points");
105     gpc1.plotXY(x, y, "user-defined points");
106     Thread.sleep(SLEEP_LGTH);
107 
108 
109     /*
110      * Multiple output screens
111      */
112 
113     writeln();
114     writeln();
115 
116     writeln("*** multiple output windows");
117     gpc1.resetPlot;
118     gpc1.setStyle("lines");
119     gpc2.setStyle("lines");
120     gpc3.setStyle("lines");
121     gpc4.setStyle("lines");
122 
123     writeln("window 1: sin(x)");
124     gpc1.plotEquation("sin(x)", "sin(x)");
125     Thread.sleep(SLEEP_LGTH) ;
126     writeln("window 2: x*sin(x)");
127     gpc2.plotEquation("x*sin(x)", "x*sin(x)");
128     Thread.sleep(SLEEP_LGTH) ;
129     writeln("window 3: log(x)/x");
130     gpc3.plotEquation("log(x)/x", "log(x)/x");
131     Thread.sleep(SLEEP_LGTH) ;
132     writeln("window 4: sin(x)/x");
133     gpc4.plotEquation("sin(x)/x", "sin(x)/x");
134     Thread.sleep(SLEEP_LGTH) ;
135     
136     gpc1.finish; 
137     gpc2.finish; 
138     gpc3.finish; 
139     gpc4.finish; 
140     writeln(); 
141     writeln();
142     writeln("*** end of gnuplot example");

Meta