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

Download this file

48 lines (38 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
44
45
46
47
package indiji.mlplot.demo;
import indiji.mlplot.MLPlot;
import indiji.mlplot.MLPlot.Style;
import indiji.mlplot.MLPlot.Symbol;
import java.io.File;
import java.util.Random;
public class Demo2 {
public static void main(String[] args){
// Create data
double x1[]=new double[1000];
double x2[]=new double[1000];
double y1[]=new double[1000];
double y2[]=new double[1000];
java.util.Random rand=new Random();
for(int n=0;n<x1.length;n++){
x1[n]=100*rand.nextGaussian();
y1[n]=rand.nextGaussian();
x2[n]=100*(rand.nextGaussian()/2+3);
y2[n]=rand.nextGaussian()*2;
}
// Create a new Plot
MLPlot p=new MLPlot();
// Draw data
p.linePlot(x1,y1,"blue",Style.None,Symbol.Plus,"Normal");
p.linePlot(x2,y2,"red",Style.None,Symbol.Star,"Transformed");
p.setTenPowerX(3);
p.setTenPowerY(-3);
// Customize Plot
p.setTitle("Scatterplots are just 'None'-styled Lineplots" );
p.setLegendMargin(70);
p.setTickLength(20);
p.setLegendPos("NW");
// Save Vector/Bitmap Graphics
p.save(new File("demo2.svg"));
p.save(new File("demo2.jpg"),800);
p.save(new File("demo2.eps"));
}
}