Skip to content

Commit eda0c3b

Browse files
committed
Create HistogramExample.md
1 parent bea78c9 commit eda0c3b

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

HistogramExample.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
```java
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+
30+
```

0 commit comments

Comments
 (0)