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

Download this file

Demo3.java    46 lines (36 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
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 Demo3 {
public static void main(String[] args){
// Create data
double x[]=new double[100];
double y_sine[]=new double[100];
double y_cosine[]=new double[100];
for(int n=0;n<x.length;n++){
double v=2*Math.PI*n/x.length;
x[n]=1.5+1000*v;
y_sine[n]=Math.pow(3,Math.sin(v)+4);
y_cosine[n]=Math.pow(4,Math.cos(v)+4);
}
// Create a new Plot
MLPlot p=new MLPlot();
// Draw data
p.linePlot(x,y_sine,"black",Style.Solid,Symbol.XMark,"Sine");
p.linePlot(x,y_cosine,"red",Style.Solid,Symbol.Plus,"Cosine");
p.setModelBounds(1, 10000, 10, 10000);
p.setLogX(true);
p.setLogY(true);
p.setMinorTicks(7);
// Customize Plot
p.setTitle("Log-Scaled Axis" );
p.setyLabelDist(p.getyLabelDist()+20);
// Save Vector/Bitmap Graphics
p.save(new File("demo3.svg"));
p.save(new File("demo3.jpg"),800);
p.save(new File("demo3.eps"));
}
}