Example usage for org.jfree.data.xy YIntervalSeries add

List of usage examples for org.jfree.data.xy YIntervalSeries add

Introduction

In this page you can find the example usage for org.jfree.data.xy YIntervalSeries add.

Prototype

public void add(double x, double y, double yLow, double yHigh) 

Source Link

Document

Adds a data item to the series and sends a SeriesChangeEvent to all registered listeners.

Usage

From source file:com.rapidminer.gui.plotter.charts.SeriesChartPlotter.java

private int prepareData() {
    synchronized (dataTable) {
        this.dataset = new YIntervalSeriesCollection();
        this.plotBounds = false;
        this.plotIndexToColumnIndexMap.clear();

        // series
        int columnCount = 0;
        for (int c = 0; c < dataTable.getNumberOfColumns(); c++) {
            if (getPlotColumn(c)) {
                if (dataTable.isNumerical(c)) {
                    YIntervalSeries series = new YIntervalSeries(this.dataTable.getColumnName(c));
                    Iterator<DataTableRow> i = dataTable.iterator();
                    int index = 0;
                    while (i.hasNext()) {
                        DataTableRow row = i.next();
                        double value = row.getValue(c);
                        if (axis[INDEX] >= 0 && !dataTable.isNominal(axis[INDEX])) {
                            double indexValue = row.getValue(axis[INDEX]);
                            series.add(indexValue, value, value, value);
                        } else {
                            series.add(index++, value, value, value);
                        }/*from   w w  w . j  a v a  2 s.c o m*/
                    }
                    dataset.addSeries(series);
                    plotIndexToColumnIndexMap.add(c);
                    columnCount++;
                }
            }
        }

        // Lower and upper bound
        if (getAxis(MIN) > -1 && getAxis(MAX) > -1) {
            if (dataTable.isNumerical(getAxis(MIN)) && dataTable.isNumerical(getAxis(MAX))) {
                YIntervalSeries series = new YIntervalSeries("Bounds");
                Iterator<DataTableRow> i = dataTable.iterator();
                int index = 0;
                while (i.hasNext()) {
                    DataTableRow row = i.next();
                    double lowerValue = row.getValue(getAxis(0));
                    double upperValue = row.getValue(getAxis(1));
                    if (lowerValue > upperValue) {
                        double dummy = lowerValue;
                        lowerValue = upperValue;
                        upperValue = dummy;
                    }
                    double mean = (upperValue - lowerValue) / 2.0d + lowerValue;
                    if (axis[INDEX] >= 0 && !dataTable.isNominal(axis[INDEX])) {
                        double indexValue = row.getValue(axis[INDEX]);
                        series.add(indexValue, mean, lowerValue, upperValue);
                    } else {
                        series.add(index++, mean, lowerValue, upperValue);
                    }
                }
                dataset.addSeries(series);
                this.plotBounds = true;
                this.boundsSeriesIndex = dataset.getSeriesCount() - 1;
            }
        }

        // limit
        if (useLimit) {
            YIntervalSeries series = new YIntervalSeries("Limit");
            int index = 0;
            for (DataTableRow row : dataTable) {
                if (!dataTable.isNominal(axis[INDEX])) {
                    double indexValue = row.getValue(axis[INDEX]);
                    series.add(indexValue, limit, limit, limit);
                } else {
                    series.add(index++, limit, limit, limit);
                }
            }
            dataset.addSeries(series);
        }

        return columnCount;
    }
}

From source file:projects.wdlf47tuc.ProcessAllSwathcal.java

/**
 * Computes the luminosity function for the current boxed region and plots it in a JFrame.
 * Also prints out the coordinates of the selection box vertices and the luminosity function
 * quantities.//from  w  ww .j av a  2s.c  om
 * 
 * @param sources
 *    The {@link Source}s to compute the luminosity function for.
 */
private void computeAndPlotLuminosityFunction(List<Source> sources) {

    // Print out coordinates of selection box corners
    System.out.println("# Coordinates of selection box corners:");
    System.out.println("# (" + col1Filter + "-" + col2Filter + ")\t" + magFilter);
    for (double[] point : points) {
        System.out.println("# " + point[0] + "\t" + point[1]);
    }
    System.out.println("# Luminosity function:");
    System.out.println("# Mag.\tN\tsigN");

    double magBinWidth = 0.5;

    // Get the range of the data
    double mMin = Double.MAX_VALUE;
    double mMax = -Double.MAX_VALUE;
    for (Source source : sources) {
        double mag = source.getMag(magFilter) - mu;
        mMin = Math.min(mMin, mag);
        mMax = Math.max(mMax, mag);
    }

    // Quantize this to a whole number
    mMin = Math.floor(mMin);
    mMax = Math.ceil(mMax);

    int nBins = (int) Math.rint((mMax - mMin) / magBinWidth);

    // Array to accumulate all objects in each bin
    int[] n = new int[nBins];

    for (Source source : sources) {
        double mag = source.getMag(magFilter) - mu;
        // Bin number
        int bin = (int) Math.floor((mag - mMin) / magBinWidth);
        n[bin]++;
    }

    YIntervalSeries luminosityFunction = new YIntervalSeries("Luminosity Function");

    for (int i = 0; i < nBins; i++) {
        // Bin centre
        double x = mMin + i * magBinWidth + 0.5 * magBinWidth;
        double y = n[i];
        double yErr = n[i] > 0 ? Math.sqrt(y) : 0;
        luminosityFunction.add(x, y, y - yErr, y + yErr);
        System.out.println(x + "\t" + y + "\t" + yErr);
    }

    final YIntervalSeriesCollection data = new YIntervalSeriesCollection();
    data.addSeries(luminosityFunction);

    XYErrorRenderer renderer = new XYErrorRenderer();
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, true);
    renderer.setSeriesShape(0, new Ellipse2D.Float(-1f, -1f, 2, 2));
    renderer.setSeriesPaint(0, ChartColor.BLACK);

    NumberAxis xAxis = new NumberAxis("Absolute Magnitude (" + magFilter.toString() + ")");
    xAxis.setAutoRange(true);
    xAxis.setAutoRangeIncludesZero(false);

    NumberAxis yAxis = new NumberAxis("N");
    yAxis.setAutoRange(true);
    yAxis.setAutoRangeIncludesZero(true);

    // Configure plot
    XYPlot xyplot = new XYPlot(data, xAxis, yAxis, renderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setDomainGridlinesVisible(true);
    xyplot.setRangeGridlinePaint(Color.white);

    // Configure chart
    JFreeChart chart = new JFreeChart("Luminosity Function", xyplot);
    chart.setBackgroundPaint(Color.white);
    chart.setTitle("47 Tuc luminosity function");
    chart.removeLegend();

    final ChartPanel lfChartPanel = new ChartPanel(chart);

    java.awt.EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            JFrame tester = new JFrame();
            tester.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            tester.setLayout(new BorderLayout());
            tester.add(lfChartPanel, BorderLayout.CENTER);
            tester.pack();
            tester.setVisible(true);
        }
    });

}

From source file:de.bund.bfr.knime.pmm.common.chart.ChartCreator.java

private void plotFunction(XYPlot plot, Plotable plotable, String id, Color defaultColor, Shape defaultShape,
        double minX, double maxX) throws ConvertException {
    double[][] points = plotable.getFunctionPoints(paramX, paramY, unitX, unitY, transformX, transformY, minX,
            maxX, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
    double[][] functionErrors = null;
    String legend = shortLegend.get(id);
    Color color = colors.get(id);
    Shape shape = shapes.get(id);

    if (showConfidenceInterval) {
        functionErrors = plotable.getFunctionErrors(paramX, paramY, unitX, unitY, transformX, transformY, minX,
                maxX, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
    }/*  ww w  .jav  a 2s . c o  m*/

    if (addInfoInLegend) {
        legend = longLegend.get(id);
    }

    if (color == null) {
        color = defaultColor;
    }

    if (shape == null) {
        shape = defaultShape;
    }

    if (points != null) {
        int i;

        if (plot.getDataset(0) == null) {
            i = 0;
        } else {
            i = plot.getDatasetCount();
        }

        if (functionErrors != null) {
            YIntervalSeriesCollection functionDataset = new YIntervalSeriesCollection();
            DeviationRenderer functionRenderer = new DeviationRenderer(true, false);
            YIntervalSeries series = new YIntervalSeries(legend);

            for (int j = 0; j < points[0].length; j++) {
                double error = Double.isNaN(functionErrors[1][j]) ? 0.0 : functionErrors[1][j];

                series.add(points[0][j], points[1][j], points[1][j] - error, points[1][j] + error);
            }

            functionDataset.addSeries(series);
            functionRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
            functionRenderer.setSeriesPaint(0, color);
            functionRenderer.setSeriesFillPaint(0, color);
            functionRenderer.setSeriesShape(0, shape);

            plot.setDataset(i, functionDataset);
            plot.setRenderer(i, functionRenderer);
        } else {
            DefaultXYDataset functionDataset = new DefaultXYDataset();
            XYLineAndShapeRenderer functionRenderer = new XYLineAndShapeRenderer(true, false);

            functionDataset.addSeries(legend, points);
            functionRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
            functionRenderer.setSeriesPaint(0, color);
            functionRenderer.setSeriesShape(0, shape);

            plot.setDataset(i, functionDataset);
            plot.setRenderer(i, functionRenderer);
        }
    }
}

From source file:de.bund.bfr.knime.pmm.common.chart.ChartCreator.java

private void plotBoth(XYPlot plot, Plotable plotable, String id, Color defaultColor, Shape defaultShape,
        double minX, double maxX) throws ConvertException {
    double[][] modelPoints = plotable.getFunctionPoints(paramX, paramY, unitX, unitY, transformX, transformY,
            minX, maxX, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
    double[][] dataPoints = plotable.getPoints(paramX, paramY, unitX, unitY, transformX, transformY);
    double[][] functionErrors = null;
    String legend = shortLegend.get(id);
    Color color = colors.get(id);
    Shape shape = shapes.get(id);

    if (showConfidenceInterval) {
        functionErrors = plotable.getFunctionErrors(paramX, paramY, unitX, unitY, transformX, transformY, minX,
                maxX, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
    }// w  w w.j  av a2s .c  om

    if (addInfoInLegend) {
        legend = longLegend.get(id);
    }

    if (color == null) {
        color = defaultColor;
    }

    if (shape == null) {
        shape = defaultShape;
    }

    if (modelPoints != null) {
        int i;

        if (plot.getDataset(0) == null) {
            i = 0;
        } else {
            i = plot.getDatasetCount();
        }

        if (functionErrors != null) {
            YIntervalSeriesCollection functionDataset = new YIntervalSeriesCollection();
            DeviationRenderer functionRenderer = new DeviationRenderer(true, false);
            YIntervalSeries series = new YIntervalSeries(legend);

            for (int j = 0; j < modelPoints[0].length; j++) {
                double error = Double.isNaN(functionErrors[1][j]) ? 0.0 : functionErrors[1][j];

                series.add(modelPoints[0][j], modelPoints[1][j], modelPoints[1][j] - error,
                        modelPoints[1][j] + error);
            }

            functionDataset.addSeries(series);
            functionRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
            functionRenderer.setSeriesPaint(0, color);
            functionRenderer.setSeriesFillPaint(0, color);
            functionRenderer.setSeriesShape(0, shape);

            if (dataPoints != null) {
                functionRenderer.setBaseSeriesVisibleInLegend(false);
            }

            plot.setDataset(i, functionDataset);
            plot.setRenderer(i, functionRenderer);
        } else {
            DefaultXYDataset functionDataset = new DefaultXYDataset();
            XYLineAndShapeRenderer functionRenderer = new XYLineAndShapeRenderer(true, false);

            functionDataset.addSeries(legend, modelPoints);
            functionRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
            functionRenderer.setSeriesPaint(0, color);
            functionRenderer.setSeriesShape(0, shape);

            if (dataPoints != null) {
                functionRenderer.setBaseSeriesVisibleInLegend(false);
            }

            plot.setDataset(i, functionDataset);
            plot.setRenderer(i, functionRenderer);
        }
    }

    if (dataPoints != null) {
        DefaultXYDataset dataSet = new DefaultXYDataset();
        XYLineAndShapeRenderer dataRenderer = new XYLineAndShapeRenderer(drawLines, true);

        dataSet.addSeries(legend, dataPoints);
        dataRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
        dataRenderer.setSeriesPaint(0, color);
        dataRenderer.setSeriesShape(0, shape);

        int i;

        if (plot.getDataset(0) == null) {
            i = 0;
        } else {
            i = plot.getDatasetCount();
        }

        plot.setDataset(i, dataSet);
        plot.setRenderer(i, dataRenderer);
    }
}

From source file:de.bund.bfr.knime.pmm.common.chart.ChartCreator.java

private void plotFunctionSample(XYPlot plot, Plotable plotable, String id, Color defaultColor,
        Shape defaultShape, double minX, double maxX, List<String> warnings) throws ConvertException {
    double[][] functionPoints = plotable.getFunctionPoints(paramX, paramY, unitX, unitY, transformX, transformY,
            minX, maxX, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
    double[][] samplePoints;

    if (!inverse) {
        samplePoints = plotable.getFunctionSamplePoints(paramX, paramY, unitX, unitY, transformX, transformY,
                minX, maxX, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, warnings);
    } else {/*from  ww w .j a  va2 s.c  o  m*/
        samplePoints = plotable.getInverseFunctionSamplePoints(paramX, paramY, unitX, unitY, transformX,
                transformY, minX, maxX, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, warnings);
    }

    double[][] functionErrors = null;
    String legend = shortLegend.get(id);
    Color color = colors.get(id);
    Shape shape = shapes.get(id);

    if (showConfidenceInterval) {
        functionErrors = plotable.getFunctionErrors(paramX, paramY, unitX, unitY, transformX, transformY, minX,
                maxX, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
    }

    if (addInfoInLegend) {
        legend = longLegend.get(id);
    }

    if (color == null) {
        color = defaultColor;
    }

    if (shape == null) {
        shape = defaultShape;
    }

    if (functionPoints != null) {
        int i;

        if (plot.getDataset(0) == null) {
            i = 0;
        } else {
            i = plot.getDatasetCount();
        }

        if (functionErrors != null) {
            YIntervalSeriesCollection functionDataset = new YIntervalSeriesCollection();
            DeviationRenderer functionRenderer = new DeviationRenderer(true, false);
            YIntervalSeries series = new YIntervalSeries(legend);

            for (int j = 0; j < functionPoints[0].length; j++) {
                double error = Double.isNaN(functionErrors[1][j]) ? 0.0 : functionErrors[1][j];

                series.add(functionPoints[0][j], functionPoints[1][j], functionPoints[1][j] - error,
                        functionPoints[1][j] + error);
            }

            functionDataset.addSeries(series);
            functionRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
            functionRenderer.setSeriesPaint(0, color);
            functionRenderer.setSeriesFillPaint(0, color);
            functionRenderer.setSeriesShape(0, shape);

            if (samplePoints != null) {
                functionRenderer.setBaseSeriesVisibleInLegend(false);
            }

            plot.setDataset(i, functionDataset);
            plot.setRenderer(i, functionRenderer);
        } else {
            DefaultXYDataset functionDataset = new DefaultXYDataset();
            XYLineAndShapeRenderer functionRenderer = new XYLineAndShapeRenderer(true, false);

            functionDataset.addSeries(legend, functionPoints);
            functionRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
            functionRenderer.setSeriesPaint(0, color);
            functionRenderer.setSeriesShape(0, shape);

            if (samplePoints != null) {
                functionRenderer.setBaseSeriesVisibleInLegend(false);
            }

            plot.setDataset(i, functionDataset);
            plot.setRenderer(i, functionRenderer);
        }

        if (samplePoints != null) {
            DefaultXYDataset sampleDataset = new DefaultXYDataset();
            XYLineAndShapeRenderer sampleRenderer = new XYLineAndShapeRenderer(false, true);

            sampleDataset.addSeries(legend, samplePoints);
            sampleRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
            sampleRenderer.setSeriesPaint(0, color);
            sampleRenderer.setSeriesShape(0, shape);

            plot.setDataset(i + 1, sampleDataset);
            plot.setRenderer(i + 1, sampleRenderer);
        }
    }
}

From source file:de.bund.bfr.knime.pmm.common.chart.ChartCreator.java

private void plotBothStrict(XYPlot plot, Plotable plotable, String id, double minX, double maxX)
        throws ConvertException {
    String legend = shortLegend.get(id);
    List<Color> colorList = colorLists.get(id);
    List<Shape> shapeList = shapeLists.get(id);
    ColorAndShapeCreator creator = new ColorAndShapeCreator(plotable.getNumberOfCombinations());
    int index = 0;

    if (addInfoInLegend) {
        legend = longLegend.get(id);//from  w  w  w .  j av a  2  s  .c o  m
    }

    if (colorList == null || colorList.isEmpty()) {
        colorList = creator.getColorList();
    }

    if (shapeList == null || shapeList.isEmpty()) {
        shapeList = creator.getShapeList();
    }

    for (Map<String, Integer> choiceMap : plotable.getAllChoices()) {
        double[][] dataPoints = plotable.getPoints(paramX, paramY, unitX, unitY, transformX, transformY,
                choiceMap);

        if (dataPoints == null) {
            continue;
        }

        double[][] modelPoints = plotable.getFunctionPoints(paramX, paramY, unitX, unitY, transformX,
                transformY, minX, maxX, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, choiceMap);

        if (modelPoints == null) {
            continue;
        }

        double[][] modelErrors = null;

        if (showConfidenceInterval) {
            modelErrors = plotable.getFunctionErrors(paramX, paramY, unitX, unitY, transformX, transformY, minX,
                    maxX, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, choiceMap);
        }

        int i;

        if (plot.getDataset(0) == null) {
            i = 0;
        } else {
            i = plot.getDatasetCount();
        }

        String addLegend = "";

        for (String arg : choiceMap.keySet()) {
            if (!arg.equals(paramX)) {
                addLegend += " (" + arg + "=" + plotable.getFunctionArguments().get(arg).get(choiceMap.get(arg))
                        + ")";
            }
        }

        if (modelErrors != null) {
            YIntervalSeriesCollection modelSet = new YIntervalSeriesCollection();
            DeviationRenderer modelRenderer = new DeviationRenderer(true, false);
            YIntervalSeries series = new YIntervalSeries(legend);

            for (int j = 0; j < modelPoints[0].length; j++) {
                double error = Double.isNaN(modelErrors[1][j]) ? 0.0 : modelErrors[1][j];

                series.add(modelPoints[0][j], modelPoints[1][j], modelPoints[1][j] - error,
                        modelPoints[1][j] + error);
            }

            modelSet.addSeries(series);
            modelRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
            modelRenderer.setSeriesPaint(0, colorList.get(index));
            modelRenderer.setSeriesFillPaint(0, colorList.get(index));
            modelRenderer.setSeriesShape(0, shapeList.get(index));

            if (dataPoints != null) {
                modelRenderer.setBaseSeriesVisibleInLegend(false);
            }

            plot.setDataset(i, modelSet);
            plot.setRenderer(i, modelRenderer);
        } else {
            DefaultXYDataset modelSet = new DefaultXYDataset();
            XYLineAndShapeRenderer modelRenderer = new XYLineAndShapeRenderer(true, false);

            modelSet.addSeries(legend + addLegend, modelPoints);
            modelRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
            modelRenderer.setBaseSeriesVisibleInLegend(false);
            modelRenderer.setSeriesPaint(0, colorList.get(index));
            modelRenderer.setSeriesShape(0, shapeList.get(index));

            plot.setDataset(i, modelSet);
            plot.setRenderer(i, modelRenderer);
        }

        DefaultXYDataset dataSet = new DefaultXYDataset();
        XYLineAndShapeRenderer dataRenderer = new XYLineAndShapeRenderer(drawLines, true);

        dataSet.addSeries(legend + addLegend, dataPoints);
        dataRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
        dataRenderer.setSeriesPaint(0, colorList.get(index));
        dataRenderer.setSeriesShape(0, shapeList.get(index));
        plot.setDataset(i + 1, dataSet);
        plot.setRenderer(i + 1, dataRenderer);

        index++;
    }
}

From source file:com.rapidminer.gui.viewer.ROCChartPlotter.java

private void prepareData() {

    this.dataset = new YIntervalSeriesCollection();

    Iterator<Map.Entry<String, List<ROCData>>> r = rocDataLists.entrySet().iterator();
    boolean showThresholds = true;
    if (rocDataLists.size() > 1) {
        showThresholds = false;//from w  ww  .j a  va  2s  .c om
    }

    while (r.hasNext()) {
        Map.Entry<String, List<ROCData>> entry = r.next();
        YIntervalSeries rocSeries = new YIntervalSeries(entry.getKey());
        YIntervalSeries thresholdSeries = new YIntervalSeries(entry.getKey() + " (Thresholds)");
        List<ROCData> dataList = entry.getValue();
        for (int i = 0; i <= NUMBER_OF_POINTS; i++) {

            double rocSum = 0.0d;
            double rocSquaredSum = 0.0d;
            double thresholdSum = 0.0d;
            double thresholdSquaredSum = 0.0d;
            for (ROCData data : dataList) {
                double rocValue = data.getInterpolatedTruePositives(i / (double) NUMBER_OF_POINTS)
                        / data.getTotalPositives();
                rocSum += rocValue;
                rocSquaredSum += rocValue * rocValue;

                double thresholdValue = data.getInterpolatedThreshold(i / (double) NUMBER_OF_POINTS);
                thresholdSum += thresholdValue;
                thresholdSquaredSum += thresholdValue * thresholdValue;
            }

            double rocMean = rocSum / dataList.size();
            double rocDeviation = Math.sqrt(rocSquaredSum / dataList.size() - (rocMean * rocMean));
            rocSeries.add(i / (double) NUMBER_OF_POINTS, rocMean, rocMean - rocDeviation,
                    rocMean + rocDeviation);

            double thresholdMean = thresholdSum / dataList.size();
            double thresholdDeviation = Math
                    .sqrt(thresholdSquaredSum / dataList.size() - (thresholdMean * thresholdMean));
            thresholdSeries.add(i / (double) NUMBER_OF_POINTS, thresholdMean,
                    thresholdMean - thresholdDeviation, thresholdMean + thresholdDeviation);

        }
        dataset.addSeries(rocSeries);

        if (showThresholds) {
            dataset.addSeries(thresholdSeries);
        }
    }
}

From source file:com.rapidminer.gui.plotter.charts.DeviationChartPlotter.java

private int prepareData() {
    // calculate min and max
    int columns = this.dataTable.getNumberOfColumns();
    double[] min = new double[columns];
    double[] max = new double[columns];
    for (int c = 0; c < columns; c++) {
        min[c] = Double.POSITIVE_INFINITY;
        max[c] = Double.NEGATIVE_INFINITY;
    }//  w  w w .j  a  va 2 s . c om

    synchronized (dataTable) {
        Iterator<DataTableRow> i = dataTable.iterator();
        while (i.hasNext()) {
            DataTableRow row = i.next();
            for (int c = 0; c < dataTable.getNumberOfColumns(); c++) {
                double value = row.getValue(c);
                min[c] = MathFunctions.robustMin(min[c], value);
                max[c] = MathFunctions.robustMax(max[c], value);
            }
        }
    }

    synchronized (dataTable) {
        this.dataset = new YIntervalSeriesCollection();
        if (colorColumn >= 0 && dataTable.isNominal(colorColumn)) {
            for (int v = 0; v < dataTable.getNumberOfValues(colorColumn); v++) {
                String valueName = dataTable.mapIndex(colorColumn, v);
                YIntervalSeries series = new YIntervalSeries(valueName);
                boolean first = true;
                List<String> domainValues = new LinkedList<String>();
                for (int column = 0; column < dataTable.getNumberOfColumns(); column++) {
                    if (!dataTable.isSpecial(column) && column != colorColumn) {
                        Iterator<DataTableRow> i = this.dataTable.iterator();
                        double sum = 0.0d;
                        double squaredSum = 0.0d;
                        int counter = 0;
                        while (i.hasNext()) {
                            DataTableRow row = i.next();
                            if (row.getValue(colorColumn) != v) {
                                continue;
                            }
                            double value = row.getValue(column);
                            sum += value;
                            squaredSum += value * value;
                            counter++;
                        }

                        double mean = sum / counter;
                        double deviation = Math.sqrt(squaredSum / counter - mean * mean);
                        if (isLocalNormalized()) {
                            mean = (mean - min[column]) / (max[column] - min[column]);
                            deviation = (deviation - min[column]) / (max[column] - min[column]);
                        }
                        series.add(column, mean, mean - deviation, mean + deviation);
                        domainValues.add(dataTable.getColumnName(column));
                    }
                }
                if (first) {
                    this.domainAxisMap = new String[domainValues.size()];
                    domainValues.toArray(this.domainAxisMap);
                }
                first = false;
                dataset.addSeries(series);
            }
            return dataTable.getNumberOfValues(colorColumn);
        } else {
            YIntervalSeries series = new YIntervalSeries(dataTable.getName());
            List<String> domainValues = new LinkedList<String>();
            for (int column = 0; column < dataTable.getNumberOfColumns(); column++) {
                if (!dataTable.isSpecial(column) && column != colorColumn) {
                    Iterator<DataTableRow> i = this.dataTable.iterator();
                    double sum = 0.0d;
                    double squaredSum = 0.0d;
                    int counter = 0;
                    while (i.hasNext()) {
                        DataTableRow row = i.next();
                        double value = row.getValue(column);
                        sum += value;
                        squaredSum += value * value;
                        counter++;
                    }

                    double mean = sum / counter;
                    double deviation = Math.sqrt(squaredSum / counter - mean * mean);
                    if (isLocalNormalized()) {
                        mean = (mean - min[column]) / (max[column] - min[column]);
                        // deviation = (deviation - min[column]) / (max[column] - min[column]);
                    }
                    series.add(column, mean, mean - deviation, mean + deviation);
                    domainValues.add(dataTable.getColumnName(column));
                }
            }
            dataset.addSeries(series);
            this.domainAxisMap = new String[domainValues.size()];
            domainValues.toArray(this.domainAxisMap);
            return 0;
        }
    }
}