Skip to content

Commit ade9fa9

Browse files
Migrating wiki contents from Google Code
0 parents  commit ade9fa9

File tree

8 files changed

+281
-0
lines changed

8 files changed

+281
-0
lines changed

CommandLineInterface.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
You can use JMathPlot in CLI to plot the content of ASCII files (same way that XMGrace). You just need to get jplot.sh for Linux/MacOS/Solaris or jplot.bat for Windows, and jmathplot.jar in the same directory.
2+
```
3+
Usage: jplot.<sh|bat> <-2D|-3D> [-l <INVISIBLE|NORTH|SOUTH|EAST|WEST>] [options] <ASCII file (n rows, m columns)> [[options] other ASCII file]
4+
[-l <INVISIBLE|NORTH|SOUTH|EAST|WEST>] giving the legend position
5+
[options] are:
6+
-t <SCATTER|LINE|BAR|HISTOGRAM2D(<integer h>)|HISTOGRAM3D(<integer h>,<integer k>)|GRID3D|CLOUD2D(<integer h>,<integer k>)|CLOUD3D(<integer h>,<integer k>,<integer l>)> type of the plot
7+
SCATTER|LINE|BAR: each line of the ASCII file contains coordinates of one point.
8+
HISTOGRAM2D(<integer h>): ASCII file contains the 1D sample (i.e. m=1) to split in h slices.
9+
HISTOGRAM3D(<integer h>,<integer k>): ASCII file contains the 2D sample (i.e. m=2) to split in h*k slices (h slices on X axis and k slices on Y axis).
10+
GRID3D: ASCII file is a matrix, first row gives n X grid values, first column gives m Y grid values, other values are Z values.
11+
CLOUD2D(<integer h>,<integer k>): ASCII file contains the 2D sample (i.e. m=2) to split in h*k slices (h slices on X axis and k slices on Y axis), density of cloud corresponds to frequency of X-Y slice in given 2D sample.
12+
CLOUD3D(<integer h>,<integer k>,<integer l>): ASCII file contains the 3D sample (i.e. m=3) to split in h*k*l slices (h slices on X axis, k slices on Y axis, l slices on Y axis), density of cloud corresponds to frequency of X-Y-Z slice in given 3D sample.
13+
-n name name of the plot
14+
-v <ASCII file (n,3|2)> vector data to add to the plot
15+
-q<X|Y|Z>(<float Q>) <ASCII file (n,1)> Q-quantile to add to the plot on <X|Y|Z> axis. Each line of the given ASCII file contains the value of quantile for probvability Q.
16+
-qP<X|Y|Z> <ASCII file (n,p)> p-quantiles density to add to the plot on <X|Y|Z> axis. Each line of the given ASCII file contains p values.
17+
-qN<X|Y|Z> <ASCII file (n,1)> Gaussian density to add to the plot on <X|Y|Z> axis. Each line of the given ASCII file contains a standard deviation.
18+
19+
Example: jplot.<sh|bat> -3D -l SOUTH -t SCATTER tmp.dat
20+
```

CustomPlotExample.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
2+
```
3+
import java.awt.*;
4+
5+
import javax.swing.*;
6+
7+
import org.math.plot.*;
8+
import org.math.plot.plotObjects.*;
9+
10+
import static java.lang.Math.*;
11+
12+
import static org.math.array.StatisticSample.*;
13+
14+
public class CustomPlotExample {
15+
public static void main(String[] args) {
16+
17+
// define your data
18+
double[] x = randomNormal(1000, 0, 1); // 1000 random numbers from a normal (Gaussian) statistical law
19+
double[] y = randomUniform(1000, -3, 3); // 1000 random numbers from a uniform statistical law
20+
21+
// create your PlotPanel (you can use it as a JPanel)
22+
Plot2DPanel plot = new Plot2DPanel();
23+
24+
// legend at SOUTH
25+
plot.addLegend("SOUTH");
26+
27+
// add the histogram (50 slices) of x to the PlotPanel
28+
plot.addHistogramPlot("Gaussian population", x, 50);
29+
30+
// add the histogram (50 slices) of y to the PlotPanel in GREEN
31+
plot.addHistogramPlot("Uniform population", Color.RED, y, 50);
32+
33+
// add a title
34+
BaseLabel title = new BaseLabel("...My nice plot...", Color.RED, 0.5, 1.1);
35+
title.setFont(new Font("Courier", Font.BOLD, 20));
36+
plot.addPlotable(title);
37+
38+
// change name of axes
39+
plot.setAxesLabels("<X>", "frequency");
40+
41+
// customize X axe
42+
// rotate light labels
43+
plot.getAxe(0).setLightLabelAngle(-PI / 4);
44+
// change axe title position relatively to the base of the plot
45+
plot.getAxe(0).setLabelPosition(0.5, -0.15);
46+
47+
// customize Y axe
48+
// rotate light labels
49+
plot.getAxe(1).setLightLabelAngle(-PI / 4);
50+
// change axe title position relatively to the base of the plot
51+
plot.getAxe(1).setLabelPosition(-0.15, 0.5);
52+
// change axe title angle
53+
plot.getAxe(1).setLabelAngle(-PI / 2);
54+
55+
// put the PlotPanel in a JFrame like a JPanel
56+
JFrame frame = new JFrame("a plot panel");
57+
frame.setSize(600, 600);
58+
frame.setContentPane(plot);
59+
frame.setVisible(true);
60+
61+
}
62+
}
63+
```

GridPlotsExample.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
2+
```
3+
import javax.swing.*;
4+
5+
import org.math.plot.*;
6+
7+
import static java.lang.Math.*;
8+
9+
import static org.math.array.DoubleArray.*;
10+
11+
public class GridPlotsExample {
12+
public static void main(String[] args) {
13+
14+
// define your data
15+
double[] x = increment(0.0, 0.1, 1.0); // x = 0.0:0.1:1.0
16+
double[] y = increment(0.0, 0.05, 1.0);// y = 0.0:0.05:1.0
17+
double[][] z1 = f1(x, y);
18+
double[][] z2 = f2(x, y);
19+
20+
// create your PlotPanel (you can use it as a JPanel) with a legend at SOUTH
21+
Plot3DPanel plot = new Plot3DPanel("SOUTH");
22+
23+
// add grid plot to the PlotPanel
24+
plot.addGridPlot("z=cos(PI*x)*sin(PI*y)", x, y, z1);
25+
plot.addGridPlot("z=sin(PI*x)*cos(PI*y)", x, y, z2);
26+
27+
// put the PlotPanel in a JFrame like a JPanel
28+
JFrame frame = new JFrame("a plot panel");
29+
frame.setSize(600, 600);
30+
frame.setContentPane(plot);
31+
frame.setVisible(true);
32+
33+
}
34+
35+
// function definition: z=cos(PI*x)*sin(PI*y)
36+
public static double f1(double x, double y) {
37+
double z = cos(x * PI) * sin(y * PI);
38+
return z;
39+
}
40+
41+
// grid version of the function
42+
public static double[][] f1(double[] x, double[] y) {
43+
double[][] z = new double[y.length][x.length];
44+
for (int i = 0; i < x.length; i++)
45+
for (int j = 0; j < y.length; j++)
46+
z[j][i] = f1(x[i], y[j]);
47+
return z;
48+
}
49+
50+
// another function definition: z=sin(PI*x)*cos(PI*y)
51+
public static double f2(double x, double y) {
52+
double z = sin(x * PI) * cos(y * PI);
53+
return z;
54+
}
55+
56+
// grid version of the function
57+
public static double[][] f2(double[] x, double[] y) {
58+
double[][] z = new double[y.length][x.length];
59+
for (int i = 0; i < x.length; i++)
60+
for (int j = 0; j < y.length; j++)
61+
z[j][i] = f2(x[i], y[j]);
62+
return z;
63+
}
64+
}
65+
```

HistogramExample.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
```
3+
import javax.swing.*;
4+
5+
import org.math.plot.*;
6+
7+
import static org.math.array.StatisticSample.*;
8+
9+
public class HistogramExample {
10+
public static void main(String[] args) {
11+
12+
// define your data
13+
double[] x = randomLogNormal(1000, 0, 0.5); // 1000 random numbers from a log normal statistical law
14+
15+
// create your PlotPanel (you can use it as a JPanel)
16+
Plot2DPanel plot = new Plot2DPanel();
17+
18+
// add the histogram (50 slices) of x to the PlotPanel
19+
plot.addHistogramPlot("Log Normal population", x, 50);
20+
21+
// put the PlotPanel in a JFrame like a JPanel
22+
JFrame frame = new JFrame("a plot panel");
23+
frame.setSize(600, 600);
24+
frame.setContentPane(plot);
25+
frame.setVisible(true);
26+
27+
}
28+
}
29+
```

LinePlotExample.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
```
3+
import javax.swing.*;
4+
5+
import org.math.plot.*;
6+
7+
public class LinePlotExample {
8+
public static void main(String[] args) {
9+
10+
// define your data
11+
double[] x = { 1, 2, 3, 4, 5, 6 };
12+
double[] y = { 45, 89, 6, 32, 63, 12 };
13+
14+
// create your PlotPanel (you can use it as a JPanel)
15+
Plot2DPanel plot = new Plot2DPanel();
16+
17+
// define the legend position
18+
plot.addLegend("SOUTH");
19+
20+
// add a line plot to the PlotPanel
21+
plot.addLinePlot("my plot", x, y);
22+
23+
// put the PlotPanel in a JFrame like a JPanel
24+
JFrame frame = new JFrame("a plot panel");
25+
frame.setSize(600, 600);
26+
frame.setContentPane(plot);
27+
frame.setVisible(true);
28+
29+
}
30+
}
31+
```

ProjectHome.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
| **Professional support is now available at https://sites.google.com/site/mulabsltd/products/jmathplot**|
2+
|:|
3+
4+
# JMathPlot: interactive 2D and 3D plots #
5+
Provides interactive 2D/3D plot (without openGL) :
6+
* 2D/3D scatter plot
7+
* 2D/3D line plot
8+
* 2D staircase plot
9+
* 2D/3D histogram plot
10+
* 2D/3D boxplot
11+
* 3D grid plot
12+
* 2D/3D quantiles on plots
13+
14+
**_Note: for a true OpenGL java plot library, try the good [jzy3d](http://code.google.com/p/jzy3d) project_**
15+
16+
# Example Java code #
17+
```
18+
import org.math.plot.*;
19+
...
20+
21+
double[] x = ...
22+
double[] y = ...
23+
24+
// create your PlotPanel (you can use it as a JPanel)
25+
Plot2DPanel plot = new Plot2DPanel();
26+
27+
// add a line plot to the PlotPanel
28+
plot.addLinePlot("my plot", x, y);
29+
30+
// put the PlotPanel in a JFrame, as a JPanel
31+
JFrame frame = new JFrame("a plot panel");
32+
frame.setContentPane(plot);
33+
frame.setVisible(true);
34+
```
35+
# Use it #
36+
1. put [jmathplot.jar](http://jmathplot.googlecode.com/svn/trunk/jmathplot/dist/jmathplot.jar) in your java classpath
37+
1. create a new PlotPanel instance: `Plot2DPanel plot = new Plot2DPanel();`
38+
1. add a plot inside `plot.addLinePlot("my plot", x, y);`
39+
1. use the PlotPanel as any Swing component (all PlotPanel extends JPanel, in fact)

Python.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
```
3+
Usage : jplot2d(data1,options,data2,options) or jplot3d(data1,options,data2,options) [data] is an array of numbers, [options] are related to previous [data] and should be :
4+
5+
-t <SCATTER|LINE|BAR|HISTOGRAM2D(<integer h>)|HISTOGRAM3D(<integer h>,<integer k>)|GRID3D|CLOUD2D(<integer h>,<integer k>)|CLOUD3D(<integer h>,<integer k>,<integer l>)> type of the plot
6+
SCATTER|LINE|BAR: each line of the ASCII file contains coordinates of one point.
7+
HISTOGRAM2D(<integer h>): ASCII file contains the 1D sample (i.e. m=1) to split in h slices.
8+
HISTOGRAM3D(<integer h>,<integer k>): ASCII file contains the 2D sample (i.e. m=2) to split in h*k slices (h slices on X axis and k slices on Y axis).
9+
GRID3D: ASCII file is a matrix, first row gives n X grid values, first column gives m Y grid values, other values are Z values.
10+
CLOUD2D(<integer h>,<integer k>): ASCII file contains the 2D sample (i.e. m=2) to split in h*k slices (h slices on X axis and k slices on Y axis), density of cloud corresponds to frequency of X-Y slice in given 2D sample.
11+
CLOUD3D(<integer h>,<integer k>,<integer l>): ASCII file contains the 3D sample (i.e. m=3) to split in h*k*l slices (h slices on X axis, k slices on Y axis, l slices on Y axis), density of cloud corresponds to frequency of X-Y-Z slice in given 3D sample.
12+
-n name name of the plot
13+
-v <ASCII file (n,3|2)> vector data to add to the plot
14+
-q<X|Y|Z>(<float Q>) <ASCII file (n,1)> Q-quantile to add to the plot on <X|Y|Z> axis. Each line of the given ASCII file contains the value of quantile for probvability Q.
15+
-qP<X|Y|Z> <ASCII file (n,p)> p-quantiles density to add to the plot on <X|Y|Z> axis. Each line of the given ASCII file contains p values.
16+
-qN<X|Y|Z> <ASCII file (n,1)> Gaussian density to add to the plot on <X|Y|Z> axis. Each line of the given ASCII file contains a standard deviation.
17+
```

Scilab.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
```
3+
Usage : jplot2d(data1,options,data2,options) or jplot3d(data1,options,data2,options) [data] is an array of numbers, [options] are related to previous [data] and should be :
4+
5+
-t <SCATTER|LINE|BAR|HISTOGRAM2D(<integer h>)|HISTOGRAM3D(<integer h>,<integer k>)|GRID3D|CLOUD2D(<integer h>,<integer k>)|CLOUD3D(<integer h>,<integer k>,<integer l>)> type of the plot
6+
SCATTER|LINE|BAR: each line of the ASCII file contains coordinates of one point.
7+
HISTOGRAM2D(<integer h>): ASCII file contains the 1D sample (i.e. m=1) to split in h slices.
8+
HISTOGRAM3D(<integer h>,<integer k>): ASCII file contains the 2D sample (i.e. m=2) to split in h*k slices (h slices on X axis and k slices on Y axis).
9+
GRID3D: ASCII file is a matrix, first row gives n X grid values, first column gives m Y grid values, other values are Z values.
10+
CLOUD2D(<integer h>,<integer k>): ASCII file contains the 2D sample (i.e. m=2) to split in h*k slices (h slices on X axis and k slices on Y axis), density of cloud corresponds to frequency of X-Y slice in given 2D sample.
11+
CLOUD3D(<integer h>,<integer k>,<integer l>): ASCII file contains the 3D sample (i.e. m=3) to split in h*k*l slices (h slices on X axis, k slices on Y axis, l slices on Y axis), density of cloud corresponds to frequency of X-Y-Z slice in given 3D sample.
12+
-n name name of the plot
13+
-v <ASCII file (n,3|2)> vector data to add to the plot
14+
-q<X|Y|Z>(<float Q>) <ASCII file (n,1)> Q-quantile to add to the plot on <X|Y|Z> axis. Each line of the given ASCII file contains the value of quantile for probvability Q.
15+
-qP<X|Y|Z> <ASCII file (n,p)> p-quantiles density to add to the plot on <X|Y|Z> axis. Each line of the given ASCII file contains p values.
16+
-qN<X|Y|Z> <ASCII file (n,1)> Gaussian density to add to the plot on <X|Y|Z> axis. Each line of the given ASCII file contains a standard deviation.
17+
```

0 commit comments

Comments
 (0)