Skip to content

Histograms2D

Will Phelps edited this page May 5, 2017 · 4 revisions

Two dimensional histograms are very similar to one dimensional histograms. Here's a basic demonstration of a 2D histogram.

JFrame frame = new JFrame("Basic GROOT Demo");
EmbeddedCanvas canvas = new EmbeddedCanvas();
frame.setSize(800,500);
H2F histogram2d = FunctionFactory.randomGausian2D(40, 0.4, 7.6, 800000, 3.3, 0.8);
histogram2d.setTitleX("Randomly Generated Function");
histogram2d.setTitleY("Randomly Generated Function");		
canvas.getPad(0).setTitle("Histogram2D Demo");
canvas.draw(histogram2d);
canvas.setFont("HanziPen TC");  
canvas.setTitleSize(32);
canvas.setAxisTitleSize(24);
canvas.setAxisLabelSize(18);
canvas.setStatBoxFontSize(18);
frame.add(canvas);
frame.setLocationRelativeTo(null);
frame.setVisible(true);

Final Result:

## Setting log scale axes ```java canvas.getPad(0).getAxisY().setLog(true); canvas.getPad(0).getAxisZ().setLog(true);

Note: It is highly recommended that you don't rely on autoscale for log scale axes

<img src="https://github.com/gavalian/groot/blob/master/images/histogram2d_log.png" width="800">
Clone this wiki locally