Menu

[r19]: / MLPlot / src / indiji / mlplot / demo / Demo4.java  Maximize  Restore  History

Download this file

44 lines (34 with data), 1.1 kB

 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
package indiji.mlplot.demo;
import indiji.mlplot.MLPlot;
import indiji.mlplot.MLPlot.Style;
import indiji.mlplot.MLPlot.Symbol;
import java.io.File;
public class Demo4 {
public static void main(String[] args){
// Create data
double x[]=new double[30];
double y_sine[]=new double[30];
double y_cosine[]=new double[30];
double y_err[]=new double[30];
double y_err2[]=new double[30];
for(int n=0;n<x.length;n++){
x[n]=2*Math.PI*n/x.length;
y_sine[n]=Math.random()/3+Math.sin(x[n]);
y_cosine[n]=Math.random()+Math.cos(x[n]);
y_err[n]=Math.random()/7;
y_err2[n]=Math.random()/3;
}
// Create a new Plot
MLPlot p=new MLPlot();
// Draw data
p.linePlot(x,y_sine,"blue",Style.Solid,Symbol.Star,"Something",3,y_err);
p.linePlot(x,y_cosine,"red",Style.Solid,Symbol.Circle,"Else",3,y_err2);
// Customize Plot
p.setTitle("..something with errorbars..");
p.setLegendPos("NE");
// Save Vector/Bitmap Graphics
p.save(new File("demo4.svg"));
p.save(new File("demo4.jpg"),800);
p.save(new File("demo4.eps"));
}
}