-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.dart
More file actions
45 lines (37 loc) · 927 Bytes
/
plot.dart
File metadata and controls
45 lines (37 loc) · 927 Bytes
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
import 'dart:io';
import 'params.dart';
void plot(
var exp, {
var format='png',
var labels=Labels.defaultLabels(),
var frm=-10.0,
var to=10.0,
var nbPoints=100,
var color='blue',
var style=Styles.lines,
var lineWidth=1,
var showZeroX=true,
var showZeroY=true,
var showGrid=false,
var out="out2d",
var width=640,
var height=480,
var scale=1
})
{
exp = exp.replaceAll('^','**');
var str = "" +
"set terminal $format size ${width*scale},${height*scale};" +
"set output '$out.$format';"+
"set samples $nbPoints;"+
"set isosamples $nbPoints;"+
(showZeroX?"set xzeroaxis;":"")+
(showZeroY?"set yzeroaxis;":"")+
(showGrid?"set grid;":"")+
"set xlabel \"${labels.xlabel}\";"+
"set ylabel \"${labels.ylabel}\";"+
"set title \" ${labels.title }\";"+
"plot [$frm:$to] $exp with $style lt rgb \"$color\" lw $lineWidth;"+
"set output;";
Process.start('gnuplot', ["-e", str]);
}