Example usage for org.jfree.data.statistics SimpleHistogramDataset setAdjustForBinSize

List of usage examples for org.jfree.data.statistics SimpleHistogramDataset setAdjustForBinSize

Introduction

In this page you can find the example usage for org.jfree.data.statistics SimpleHistogramDataset setAdjustForBinSize.

Prototype

public void setAdjustForBinSize(boolean adjust) 

Source Link

Document

Sets the flag that controls whether or not the bin count is divided by the bin size in the #getYValue(int,int) method, and sends a DatasetChangeEvent to all registered listeners.

Usage

From source file:ch.zhaw.ias.dito.ui.AnalysisPanel.java

private JFreeChart createHistogramChart(String title, Matrix distanceMatrix) {
    int NUM_OF_BINS = 50;
    SimpleHistogramDataset dataset = new SimpleHistogramDataset("");
    dataset.setAdjustForBinSize(false);
    double min = distanceMatrix.extremum(false);
    double max = distanceMatrix.extremum(true);
    double spacing = (max - min) / NUM_OF_BINS;
    double currentBound = min;

    for (int i = 0; i < NUM_OF_BINS - 1; i++) {
        dataset.addBin(new SimpleHistogramBin(currentBound, (currentBound + spacing), true, false));
        currentBound += spacing;/*  w  w  w . ja v a 2  s  .c o  m*/
    }
    //ensure that the maximum is included and not lost because of numerical problems
    dataset.addBin(new SimpleHistogramBin(currentBound, max, true, true));
    for (int i = 0; i < distanceMatrix.getColCount(); i++) {
        DVector v = distanceMatrix.col(i);
        dataset.addObservations(v.getValues());
    }
    return ChartFactory.createHistogram(title, Translation.INSTANCE.get("misc.graphic.distance"),
            Translation.INSTANCE.get("misc.graphic.frequency"), dataset, PlotOrientation.VERTICAL, false, true,
            false);
}