List of usage examples for org.jfree.data.statistics DefaultBoxAndWhiskerCategoryDataset DefaultBoxAndWhiskerCategoryDataset
public DefaultBoxAndWhiskerCategoryDataset()
From source file:playground.anhorni.surprice.analysis.SupriceBoxPlot.java
public SupriceBoxPlot(final String chartTitle, String xAxisName, String yAxisName, double yrangeLower, double yrangeUpper) { dataset = new DefaultBoxAndWhiskerCategoryDataset(); this.chartTitle = chartTitle; this.xAxisName = xAxisName; this.yAxisName = yAxisName; this.yrangeLower = yrangeLower; this.yrangeUpper = yrangeUpper; }
From source file:org.matsim.counts.algorithms.graphs.BoxPlotErrorGraph.java
@SuppressWarnings("unchecked") @Override/*from w ww . ja va 2 s. c o m*/ public JFreeChart createChart(final int nbr) { DefaultBoxAndWhiskerCategoryDataset dataset0 = new DefaultBoxAndWhiskerCategoryDataset(); DefaultBoxAndWhiskerCategoryDataset dataset1 = new DefaultBoxAndWhiskerCategoryDataset(); final ArrayList<Double>[] listRel = new ArrayList[24]; final ArrayList<Double>[] listAbs = new ArrayList[24]; // init for (int i = 0; i < 24; i++) { listRel[i] = new ArrayList<Double>(); listAbs[i] = new ArrayList<Double>(); } // add the values of all counting stations to each hour for (CountSimComparison cc : this.ccl_) { int hour = cc.getHour() - 1; listRel[hour].add(cc.calculateRelativeError()); listAbs[hour].add(cc.getSimulationValue() - cc.getCountValue()); } // add the collected values to the graph / dataset for (int i = 0; i < 24; i++) { dataset0.add(listRel[i], "Rel Error", Integer.toString(i + 1)); dataset1.add(listAbs[i], "Abs Error", Integer.toString(i + 1)); } String title = "Iteration: " + this.iteration_; final CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(); final CategoryAxis xAxis = new CategoryAxis("Hour"); final NumberAxis yAxis0 = new NumberAxis("Signed Rel. Error [%]"); final NumberAxis yAxis1 = new NumberAxis("Signed Abs. Error [veh]"); yAxis0.setAutoRangeIncludesZero(false); yAxis1.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesToolTipGenerator(0, new BoxAndWhiskerToolTipGenerator()); CategoryPlot subplot0 = new CategoryPlot(dataset0, xAxis, yAxis0, renderer); CategoryPlot subplot1 = new CategoryPlot(dataset1, xAxis, yAxis1, renderer); plot.add(subplot0); plot.add(subplot1); final CategoryAxis axis1 = new CategoryAxis("hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); axis1.setCategoryLabelPositions(CategoryLabelPositions.UP_45); plot.setDomainAxis(axis1); this.chart_ = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 14), plot, false); return this.chart_; }
From source file:org.matsim.counts.algorithms.graphs.BoxPlotNormalizedErrorGraph.java
@SuppressWarnings("unchecked") @Override//from w w w.j a v a2 s.c o m public JFreeChart createChart(final int nbr) { DefaultBoxAndWhiskerCategoryDataset dataset0 = new DefaultBoxAndWhiskerCategoryDataset(); DefaultBoxAndWhiskerCategoryDataset dataset1 = new DefaultBoxAndWhiskerCategoryDataset(); final ArrayList<Double>[] listRel = new ArrayList[24]; final ArrayList<Double>[] listAbs = new ArrayList[24]; // init for (int i = 0; i < 24; i++) { listRel[i] = new ArrayList<Double>(); listAbs[i] = new ArrayList<Double>(); } // add the values of all counting stations to each hour for (CountSimComparison cc : this.ccl_) { int hour = cc.getHour() - 1; listRel[hour].add(cc.calculateNormalizedRelativeError() * 100); listAbs[hour].add(cc.getSimulationValue() - cc.getCountValue()); } // add the collected values to the graph / dataset for (int i = 0; i < 24; i++) { dataset0.add(listRel[i], "Rel Norm Error", Integer.toString(i + 1)); dataset1.add(listAbs[i], "Abs Error", Integer.toString(i + 1)); } String title = "Iteration: " + this.iteration_; final CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(); final CategoryAxis xAxis = new CategoryAxis("Hour"); final NumberAxis yAxis0 = new NumberAxis("Norm. Rel. Error [%]"); final NumberAxis yAxis1 = new NumberAxis("Signed Abs. Error [veh]"); yAxis0.setAutoRangeIncludesZero(false); yAxis1.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesToolTipGenerator(0, new BoxAndWhiskerToolTipGenerator()); CategoryPlot subplot0 = new CategoryPlot(dataset0, xAxis, yAxis0, renderer); CategoryPlot subplot1 = new CategoryPlot(dataset1, xAxis, yAxis1, renderer); plot.add(subplot0); plot.add(subplot1); final CategoryAxis axis1 = new CategoryAxis("hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); axis1.setCategoryLabelPositions(CategoryLabelPositions.UP_45); plot.setDomainAxis(axis1); this.chart_ = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 14), plot, false); return this.chart_; }
From source file:org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDatasetTest.java
/** * Confirm that the equals method can distinguish all the required fields. *//*from w ww . j a v a 2 s .c o m*/ @Test public void testEquals() { DefaultBoxAndWhiskerCategoryDataset d1 = new DefaultBoxAndWhiskerCategoryDataset(); d1.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(5.0), new Double(6.0), new Double(7.0), new Double(8.0), new ArrayList()), "ROW1", "COLUMN1"); DefaultBoxAndWhiskerCategoryDataset d2 = new DefaultBoxAndWhiskerCategoryDataset(); d2.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(5.0), new Double(6.0), new Double(7.0), new Double(8.0), new ArrayList()), "ROW1", "COLUMN1"); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); }
From source file:adapters.BoxSeriesCollectionAdapter.java
/** * Modified Method: change label from serie to Cluster plus the number of instances in the cluster * * Creates a new <TT>BoxSeriesCollection</TT> instance with default * parameters and given data series. The input parameter represents series * of point sets.//from w ww . j av a2s. com * * @param data series of point sets. * * */ public BoxSeriesCollectionAdapter(double[]... data) { renderer = new BoxAndWhiskerRenderer(); seriesCollection = new DefaultBoxAndWhiskerCategoryDataset(); DefaultBoxAndWhiskerCategoryDataset tempSeriesCollection = (DefaultBoxAndWhiskerCategoryDataset) seriesCollection; for (int i = 0; i < data.length; i++) { if (data[i].length == 0) throw new IllegalArgumentException("Unable to render the plot. data[" + i + "] contains no row"); final List<Double> list = new ArrayList<Double>(); for (int j = 0; j < data[i].length - 1; j++) list.add(data[i][j]); // "i + 1" since the cluster label should start with 1 instead of 0 tempSeriesCollection.add(list, 0, "[ " + data[i].length + " ]"); list.clear(); } ((BoxAndWhiskerRenderer) renderer).setMaximumBarWidth(BARWIDTH); }
From source file:umontreal.iro.lecuyer.charts.BoxSeriesCollection.java
/** * Creates a new <TT>BoxSeriesCollection</TT> instance with default parameters * and input series <TT>data</TT>. Only <SPAN CLASS="textit">the first</SPAN> <TT>numPoints</TT> * of <TT>data</TT> will taken into account. * /*from w w w . j a va 2 s .co m*/ * @param data point sets. * * @param numPoints Number of points * * */ public BoxSeriesCollection(double[] data, int numPoints) { renderer = new BoxAndWhiskerRenderer(); ((BoxAndWhiskerRenderer) renderer).setMaximumBarWidth(BARWIDTH); seriesCollection = new DefaultBoxAndWhiskerCategoryDataset(); DefaultBoxAndWhiskerCategoryDataset tempSeriesCollection = (DefaultBoxAndWhiskerCategoryDataset) seriesCollection; final List<Double> list = new ArrayList<Double>(); for (int i = 0; i < numPoints; i++) list.add(data[i]); tempSeriesCollection.add(list, 0, 0); }
From source file:playground.anhorni.counts.StdDevBoxPlot.java
public JFreeChart createChart() { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); ArrayList<Double>[] lists = this.createArrayLists(); // add the collected values to the graph / dataset for (int i = 0; i < 24; i++) { dataset.add(lists[i], "hour", Integer.toString(i + 1)); }/* w w w . jav a 2 s .co m*/ final CategoryAxis xAxis = new CategoryAxis(xlabel); xAxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 10)); //xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); final NumberAxis yAxis = new NumberAxis(ylabel); yAxis.setAutoRangeIncludesZero(true); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false); renderer.setSeriesPaint(0, Color.blue); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); this.chart_ = new JFreeChart(chartTitle, new Font("SansSerif", Font.BOLD, 14), plot, false); return this.chart_; }
From source file:net.sf.maltcms.chromaui.normalization.spi.charts.PeakGroupRtBoxPlot.java
public List<JFreeChart> createChart() { List<JFreeChart> charts = new ArrayList<>(); LinkedHashSet<ITreatmentGroupDescriptor> treatmentGroups = new LinkedHashSet<>( project.getTreatmentGroups()); List<CategoryPlot> plots = new LinkedList<>(); for (IPeakGroupDescriptor pgd : pgdl) { LinkedHashMap<ITreatmentGroupDescriptor, HashSet<IPeakAnnotationDescriptor>> map = new LinkedHashMap<>(); for (ITreatmentGroupDescriptor itgd : treatmentGroups) { map.put(itgd, new LinkedHashSet<IPeakAnnotationDescriptor>()); }/*from w w w . ja v a 2s. co m*/ List<IPeakAnnotationDescriptor> descriptors = pgd.getPeakAnnotationDescriptors(); DefaultBoxAndWhiskerCategoryDataset baw = new DefaultBoxAndWhiskerCategoryDataset(); for (IPeakAnnotationDescriptor ipad : descriptors) { ITreatmentGroupDescriptor treatmentGroup = ipad.getChromatogramDescriptor().getTreatmentGroup(); HashSet<IPeakAnnotationDescriptor> descr = map.get(treatmentGroup); if (descr == null) { descr = new HashSet<>(); map.put(treatmentGroup, descr); } descr.add(ipad); } List<Color> colors = new LinkedList<>(); for (ITreatmentGroupDescriptor tgd : map.keySet()) { String name = getPeakName(pgd); baw.add(createBoxAndWhiskerItem(map.get(tgd)), tgd.getName() + " (" + map.get(tgd).size() + ")", name); colors.add(tgd.getColor()); } BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(true); renderer.setMeanVisible(false); renderer.setMedianVisible(true); renderer.setArtifactPaint(new Color(0, 0, 0, 128)); renderer.setMaximumBarWidth(0.1); renderer.setUseOutlinePaintForWhiskers(false); // renderer.setAutoPopulateSeriesFillPaint(true); // renderer.setAutoPopulateSeriesPaint(true); // renderer.setAutoPopulateSeriesOutlinePaint(true); NumberAxis yAxis = new NumberAxis("Peak Apex Retention Time"); yAxis.setAutoRange(true); yAxis.setAutoRangeIncludesZero(false); CategoryPlot cp = new CategoryPlot(baw, new CategoryAxis("Treatment Groups"), yAxis, renderer); Logger.getLogger(getClass().getName()).log(Level.INFO, "Setting {0} colors!", colors.size()); ChartCustomizer.setSeriesColors(cp, 0.6f, colors); // ChartCustomizer.setSeriesColors(cp, 0.9f,colors); plots.add(cp); JFreeChart chart = new JFreeChart(cp); chart.setTitle( "Peak group " + pgd.getDisplayName() + " size: " + pgd.getPeakAnnotationDescriptors().size()); charts.add(chart); } // CategoryAxis ca = new CategoryAxis("Treatment Groups"); // NumberAxis va = new NumberAxis("Normalized Peak Area"); // CombinedDomainCategoryPlot cdcp = new CombinedDomainCategoryPlot(ca); // for (CategoryPlot cp : plots) { // cp.setRangeAxis(va); // cdcp.add(cp); // break; // } // return new JFreeChart(cdcp); return charts; }
From source file:edu.ucla.stat.SOCR.chart.demo.BoxAndWhiskerChartDemo1.java
/** * Returns a sample dataset.//from w w w . ja v a 2 s. c o m * * @return The dataset. */ protected BoxAndWhiskerCategoryDataset createDataset(boolean isDemo) { if (isDemo) { SERIES_COUNT = 3; CATEGORY_COUNT = 2; VALUE_COUNT = 10; values_storage = new String[SERIES_COUNT][CATEGORY_COUNT]; DefaultBoxAndWhiskerCategoryDataset result = new DefaultBoxAndWhiskerCategoryDataset(); for (int s = 0; s < SERIES_COUNT; s++) { for (int c = 0; c < CATEGORY_COUNT; c++) { List values = createValueList(0, 20.0, VALUE_COUNT); values_storage[s][c] = vs; result.add(values, "Series " + s, "Category " + c); } } return result; } else return super.createDataset(false); }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.boxcharts.BoxCharts.java
/** * Inherited by IChart: calculates chart value. * /*from ww w. ja v a2 s .c om*/ * @return the dataset * * @throws Exception the exception */ public DatasetMap calculateValue() throws Exception { logger.debug("IN"); String res = DataSetAccessFunctions.getDataSetResultFromId(profile, getData(), parametersObject); categories = new HashMap(); DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); SourceBean sbRows = SourceBean.fromXMLString(res); List listAtts = sbRows.getAttributeAsList("ROW"); // run all categories (one for each row) categoriesNumber = 0; boolean first = true; boolean first2 = true; double temp; for (Iterator iterator = listAtts.iterator(); iterator.hasNext();) { SourceBean category = (SourceBean) iterator.next(); List atts = category.getContainedAttributes(); // atts are all the serie, run through them and sets what you need List values = new ArrayList(); String nameP = ""; String value = ""; String catValue = ""; if (first2) { if (name.indexOf("$F{") >= 0) { setTitleParameter(atts); } if (getSubName() != null && getSubName().indexOf("$F") >= 0) { setSubTitleParameter(atts); } first2 = false; } for (Iterator iterator2 = atts.iterator(); iterator2.hasNext();) { SourceBeanAttribute object = (SourceBeanAttribute) iterator2.next(); nameP = new String(object.getKey()); value = new String((String) object.getValue()); if (nameP.equalsIgnoreCase("x")) { catValue = value; categoriesNumber = categoriesNumber + 1; categories.put(new Integer(categoriesNumber), value); } else { Double valore = Double.valueOf(value); // set minimum e maximus to avoid auto range of axis if (first) { min = valore.doubleValue(); max = valore.doubleValue(); first = false; } if (min > valore.doubleValue()) min = valore.doubleValue(); if (max < valore.doubleValue()) max = valore.doubleValue(); values.add(valore); } } dataset.add(values, "serie", catValue); } logger.debug("OUT"); DatasetMap datasets = new DatasetMap(); datasets.addDataset("1", dataset); return datasets; }