List of usage examples for org.jfree.data.xy YIntervalSeriesCollection addSeries
public void addSeries(YIntervalSeries series)
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); }//w ww . j a v a2 s. 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 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 ww . ja v a2 s. co 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: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); }/*from w w w. j a va 2s. 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 w w w . ja v a 2s . com 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:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.analysis.diagnostics.LinePlot.java
/** * Generates the quantile series for the specified key. * //w ww .ja va 2s . c o m * @param key the key identifying which result to plot * @param dataset the dataset to store the generated series */ protected void generateQuantileSeries(ResultKey key, YIntervalSeriesCollection dataset) { List<DataPoint> dataPoints = new ArrayList<DataPoint>(); for (Accumulator accumulator : controller.get(key)) { if (!accumulator.keySet().contains(metric)) { continue; } for (int i = 0; i < accumulator.size(metric); i++) { dataPoints.add(new DataPoint((Integer) accumulator.get("NFE", i), ((Number) accumulator.get(metric, i)).doubleValue())); } } Collections.sort(dataPoints); YIntervalSeries series = new YIntervalSeries(key); DescriptiveStatistics statistics = new DescriptiveStatistics(); int index = 0; int currentNFE = RESOLUTION; while (index < dataPoints.size()) { DataPoint point = dataPoints.get(index); if (point.getNFE() <= currentNFE) { statistics.addValue(point.getValue()); index++; } else { if (statistics.getN() > 0) { series.add(currentNFE, statistics.getPercentile(50), statistics.getPercentile(25), statistics.getPercentile(75)); } statistics.clear(); currentNFE += RESOLUTION; } } if (statistics.getN() > 0) { //if only entry, add extra point to display non-zero width if (series.isEmpty()) { series.add(currentNFE - RESOLUTION, statistics.getPercentile(50), statistics.getPercentile(25), statistics.getPercentile(75)); } series.add(currentNFE, statistics.getPercentile(50), statistics.getPercentile(25), statistics.getPercentile(75)); } dataset.addSeries(series); }