Example usage for org.jfree.data.statistics HistogramType RELATIVE_FREQUENCY

List of usage examples for org.jfree.data.statistics HistogramType RELATIVE_FREQUENCY

Introduction

In this page you can find the example usage for org.jfree.data.statistics HistogramType RELATIVE_FREQUENCY.

Prototype

HistogramType RELATIVE_FREQUENCY

To view the source code for org.jfree.data.statistics HistogramType RELATIVE_FREQUENCY.

Click Source Link

Document

Relative frequency.

Usage

From source file:es.uvigo.darwin.jmodeltest.io.RFHistogram.java

private static JFreeChart buildHistogram(double[] values, int steps, String plotTitle, String xAxis,
        String yAxis) {/*from w ww .j  a v  a 2  s .c o  m*/
    HistogramDataset hds = new HistogramDataset();
    hds.setType(HistogramType.RELATIVE_FREQUENCY);
    hds.addSeries(1, values, steps);
    PlotOrientation orientation = PlotOrientation.VERTICAL;
    boolean show = false;
    boolean toolTips = false;
    boolean urls = false;
    JFreeChart chart = ChartFactory.createHistogram(plotTitle, xAxis, yAxis, hds, orientation, show, toolTips,
            urls);
    return chart;
}

From source file:pertchart.Histogram.java

public JFreeChart createHistorgram(double[] data) {

    HistogramDataset dataset = new HistogramDataset();
    dataset.setType(HistogramType.RELATIVE_FREQUENCY);
    dataset.addSeries("Histogram", data, this.bins);
    String plotTitle = "Project Completion Times";
    String xaxis = "Completion Times";
    String yaxis = "";
    PlotOrientation orientation = PlotOrientation.VERTICAL;
    boolean show = false;
    boolean toolTips = false;
    boolean urls = false;
    JFreeChart chart = ChartFactory.createHistogram(plotTitle, xaxis, yaxis, dataset, orientation, show,
            toolTips, urls);/* ww w  .  ja  v  a 2 s  . com*/
    int width = 500;
    int height = 300;
    try {
        ChartUtilities.saveChartAsPNG(new File("histogram.png"), chart, width, height);
    } catch (Exception e) {
        System.out.println(e);
    }
    return chart;
}

From source file:org.jfree.chart.demo.HistogramDemo.java

/**
 * Creates a sample {@link HistogramDataset}.
 * //from   w  w  w.ja v  a 2 s . c  o  m
 * @return The dataset.
 */
private IntervalXYDataset createDataset() {
    final HistogramDataset dataset = new HistogramDataset();
    dataset.setType(HistogramType.RELATIVE_FREQUENCY);
    dataset.addSeries("H1", gaussianData(1000, 3.0), 20);
    dataset.addSeries("H0", gaussianData(1000, 0), 20);
    return dataset;
}

From source file:edu.gmu.cs.sim.util.media.chart.HistogramGenerator.java

public HistogramGenerator() {
    // buildChart is called by super() first

    LabelledList list = new LabelledList("Show Histogram...");
    DisclosurePanel pan1 = new DisclosurePanel("Show Histogram...", list);

    final HistogramType[] styles = new HistogramType[] { HistogramType.FREQUENCY,
            HistogramType.RELATIVE_FREQUENCY, HistogramType.SCALE_AREA_TO_1 };
    final JComboBox style = new JComboBox(
            new String[] { "By Frequency", "By Relative Frequency", "With Area = 1.0" });
    style.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            histogramType = styles[style.getSelectedIndex()];
            HistogramDataset dataset = (HistogramDataset) (getSeriesDataset());
            dataset.setType(histogramType);
        }//w  ww .jav a2s  .co m
    });
    list.add(style);
    addGlobalAttribute(pan1);
}

From source file:Core.CircuitEvolution.QPace4.HistogramDemo.java

/**
 * Creates a sample {@link HistogramDataset}.
 * /*from  w w w .  j  a va 2  s.  co  m*/
 * @return The dataset.
 */
private IntervalXYDataset createDataset() {
    HistogramDataset dataset = new HistogramDataset();
    dataset.setType(HistogramType.RELATIVE_FREQUENCY);
    dataset.addSeries("H1", gaussianData(1000, 3.0), 20);
    dataset.addSeries("H0", gaussianData(1000, 0), 20);
    return dataset;
}

From source file:net.imglib2.script.analysis.Histogram.java

/** Return the JFreeChart with this histogram, and as a side effect, show it in a JFrame
 * that provides the means to edit the dimensions and also the plot properties via a popup menu. */
public JFreeChart asChart(final boolean show) {
    double[] d = new double[this.size()];
    int i = 0;/*from  w  w  w . j a v  a2 s  . com*/
    for (Number num : this.values())
        d[i++] = num.doubleValue();
    HistogramDataset hd = new HistogramDataset();
    hd.setType(HistogramType.RELATIVE_FREQUENCY);
    String title = "Histogram";
    hd.addSeries(title, d, d.length);
    JFreeChart chart = ChartFactory.createHistogram(title, "", "", hd, PlotOrientation.VERTICAL, false, false,
            false);
    setTheme(chart);
    if (show) {
        JFrame frame = new JFrame(title);
        frame.getContentPane().add(new ChartPanel(chart));
        frame.pack();
        frame.setVisible(true);
    }
    return chart;
}

From source file:v800_trainer.JHistogram.java

public JPanel StartHistoHf(JCicloTronic JTronicHandle) {

    boolean Summenhisto;
    int von = 0;//from  www . j  a v a  2  s.  c o m
    int bis = 0;
    int num = 0;
    int selected;
    int single;
    int Gruppen = 0;
    int i = 100;
    int j = 10;
    int m = 0;
    int n = 0;
    int Linecount = 0;
    int Anzahl = 1;

    JFreeChart chart;

    double DummyData[] = new double[1];

    selected = JTronicHandle.Auswahl_Histogramm.getSelectedIndex();
    Summenhisto = JTronicHandle.Summenhistogramm_Check.isSelected();

    chart = ChartFactory.createHistogram("", "Herzfrequenz [p/min]", "Hufigkeit", new HistogramDataset(),
            PlotOrientation.HORIZONTAL, true, true, true);

    chart.setBackgroundPaint(Color.white);

    JTronicHandle.applyChartTheme(chart);

    XYPlot plot = chart.getXYPlot();
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.getRangeAxis().setFixedDimension(15.0);

    ArrayList Bufferarray = new ArrayList();
    double Buffer;

    if (selected == 0) {
        single = 1;
    } else {
        single = 0;
        Summenhisto = false;
    } //einzelne Tour oder alle Touren

    von = Integer.parseInt(JTronicHandle.Properties.getProperty("HistovonHf", "100"));
    bis = Integer.parseInt(JTronicHandle.Properties.getProperty("HistobisHf", "200"));
    Gruppen = Integer.parseInt(JTronicHandle.Properties.getProperty("HistostepHf", "10"));
    Anzahl = (JTronicHandle.Auswahl_Histogramm.getItemCount() - 2) * single + 1; //komische Mathe;
    //wenn nur eine Tour ausgewhlt ist single = 0  und damit Anzahl =1
    // sonst single gleich 1 und die Anzahl ist ItemCont - 1
    for (j = 0; j < Anzahl; j++) {
        if (single == 1) {
            selected = j + 1; // single = 1 => Summe ist ausgewhlt und selected muss ein hher gesetz werden
        }
        if (!Summenhisto) {
            num = JTronicHandle.Statistikhandle.TourData[selected].Datenpunkte;
        } else {
            num += JTronicHandle.Statistikhandle.TourData[selected].Datenpunkte;
        }

        n = 0;

        if (!Summenhisto) {
            create_Start_Stop(JTronicHandle, selected); //die limits einer gezoomten Graphik ermitteln
            for (i = start; i < stop; i++) { //hier wird nun ber alle Daten gezhlt
                Buffer = (double) JTronicHandle.Statistikhandle.TourData[selected].Hf_gesZeit[i]; //aktueller Wert zwischengespeichert
                if (Buffer >= von && Buffer <= bis) {
                    Bufferarray.add(Buffer); //wenn im ges. Intervall dann in das Bufferarray
                }
            }
        } else { //Summenhist ist ausgewhlt
            for (i = 0; i < j + 1; i++) { //schlechte Schleifensteuerung i=1;i<j htte es auch getan

                create_Start_Stop(JTronicHandle, i + 1);
                for (m = start; m < stop; m++) { // Schleife ber alle Datenpunkte
                    Buffer = (double) JTronicHandle.Statistikhandle.TourData[i + 1].Hf_gesZeit[m];
                    if (Buffer >= von && Buffer <= bis) {
                        Bufferarray.add(Buffer);
                    }
                }

            }
        }

        DummyData = new double[Bufferarray.size()];

        for (i = 0; i < Bufferarray.size(); i++) {
            DummyData[i] = new Double(Bufferarray.get(i).toString());
        }

        if (!Summenhisto) {
            HistogramDataset histoHF = new HistogramDataset();
            histoHF.addSeries(
                    "" + JTronicHandle.Statistikhandle.TourData[selected].Tag + "."
                            + JTronicHandle.Statistikhandle.TourData[selected].Monat + "."
                            + JTronicHandle.Statistikhandle.TourData[selected].Jahr,
                    DummyData, Gruppen, (double) von, (double) bis);
            histoHF.setType(HistogramType.RELATIVE_FREQUENCY);
            plot.setDataset(Linecount, histoHF);
            plot.mapDatasetToRangeAxis(Linecount, 0);
            XYBarRenderer renderer = new XYBarRenderer();
            renderer.setDrawBarOutline(true);
            //                renderer.setShadowVisible(false);

            renderer.setSeriesPaint(0, getColour(Linecount, (int) 255 / Anzahl));

            renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
            plot.setRenderer(Linecount, renderer);

        }
        Linecount++;
    }

    if (Summenhisto) {
        HistogramDataset histoHF = new HistogramDataset();
        histoHF.addSeries("Summenhistogram", DummyData, Gruppen, (double) von, (double) bis);
        histoHF.setType(HistogramType.RELATIVE_FREQUENCY);

        plot.setDataset(0, histoHF);
        plot.mapDatasetToRangeAxis(0, 0);
        XYItemRenderer renderer = new XYBarRenderer();
        renderer.setSeriesPaint(0, Color.blue);
        renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());

        plot.setRenderer(0, renderer);
    }

    chart.setPadding(padding);
    ChartPanel Panel = new ChartPanel(chart);

    return Panel;
}

From source file:org.locationtech.udig.processingtoolbox.tools.HistogramDialog.java

private void createInputTab(final CTabFolder parentTabFolder) {
    inputTab = new CTabItem(parentTabFolder, SWT.NONE);
    inputTab.setText(Messages.ProcessExecutionDialog_tabparameters);

    ScrolledComposite scroller = new ScrolledComposite(parentTabFolder, SWT.NONE | SWT.V_SCROLL | SWT.H_SCROLL);
    scroller.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    Composite container = new Composite(scroller, SWT.NONE);
    container.setLayout(new GridLayout(2, false));
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    // local moran's i
    Image image = ToolboxPlugin.getImageDescriptor("icons/public_co.gif").createImage(); //$NON-NLS-1$
    uiBuilder.createLabel(container, Messages.HistogramDialog_InputLayer, EMPTY, image, 2);
    cboLayer = uiBuilder.createCombo(container, 2, true);
    fillLayers(map, cboLayer, VectorLayerType.ALL);

    uiBuilder.createLabel(container, Messages.HistogramDialog_InputField, EMPTY, image, 2);
    cboField = uiBuilder.createCombo(container, 2, true);

    uiBuilder.createLabel(container, Messages.HistogramDialog_BinCount, EMPTY, image, 2);
    spinner = uiBuilder.createSpinner(container, 10, 1, 50, 0, 1, 5, 2);

    // yXais Type
    uiBuilder.createLabel(container, Messages.HistogramDialog_YAxisType, EMPTY, image, 1);
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = 0;/*from   w ww.  j  av  a 2s  . c  om*/

    Composite subCon = new Composite(container, SWT.NONE);
    subCon.setLayout(layout);
    subCon.setLayoutData(new GridData(SWT.LEFT_TO_RIGHT, SWT.CENTER, false, false, 1, 1));
    final Button chkRatio = uiBuilder.createRadioButton(subCon, Messages.HistogramDialog_Ratio, null, 1);
    final Button chkFrequency = uiBuilder.createRadioButton(subCon, Messages.HistogramDialog_Frequency, null,
            1);
    chkFrequency.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            if (chkFrequency.getSelection()) {
                histogramType = HistogramType.FREQUENCY;
            }
        }
    });
    chkRatio.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            if (chkRatio.getSelection()) {
                histogramType = HistogramType.RELATIVE_FREQUENCY;
            }
        }
    });
    chkRatio.setSelection(true);

    uiBuilder.createLabel(container, null, null, 2);
    chkStatistics = uiBuilder.createCheckbox(container, Messages.ScatterPlotDialog_BasicStatistics, null, 2);

    // register events
    cboLayer.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            inputLayer = MapUtils.getLayer(map, cboLayer.getText());
            if (inputLayer != null) {
                fillFields(cboField, inputLayer.getSchema(), FieldType.Number);
            }
        }
    });

    // finally
    scroller.setContent(container);
    inputTab.setControl(scroller);

    scroller.setMinSize(450, container.getSize().y - 2);
    scroller.setExpandVertical(true);
    scroller.setExpandHorizontal(true);

    scroller.pack();
    container.pack();
}

From source file:org.ect.reo.simulation.views.SimulationViewResults.java

private static JFreeChart createHistogram(Statistic statistic, Composite composite) {
    HistogramDataset dataset = new HistogramDataset();
    dataset.setType(HistogramType.RELATIVE_FREQUENCY);
    int numOfBatches = Integer.parseInt(SimulationViewOptions.batchNumberText.getText());
    double[] values = new double[numOfBatches];

    for (int i = 0; i < numOfBatches; i++) {
        values[i] = statistic.getStatisticValue(i);
    }/*from   w  w w .  j av  a  2  s.  c om*/

    try {
        dataset.addSeries("Histogram of batch values", values,
                (int) Math.ceil(Math.log(numOfBatches) / Math.log(2) + 1));
        return ChartFactory.createHistogram("Batch results", "Value", "Relative frequency", dataset,
                PlotOrientation.VERTICAL, false, true, false);
    } catch (Throwable t) {
        return null;
    }
}

From source file:playground.anhorni.surprice.analysis.ModeSharesEventHandler.java

public HistogramDataset getHistogramDataset(final int nBins) {
    HistogramDataset output = new HistogramDataset();
    output.setType(HistogramType.RELATIVE_FREQUENCY);
    ArrayList<Double> croppedData = new ArrayList<Double>();

    for (String mode : this.rawData.keySet()) {
        for (double d : this.rawData.get(mode).getElements()) {
            if (d < this.maxXYForPlotting) {
                croppedData.add(d);//ww  w .j a v a2  s .  co m
            }
        }
        output.addSeries(mode, Utils.convert(croppedData), nBins);
    }
    return output;
}