List of usage examples for org.jfree.data.statistics DefaultBoxAndWhiskerCategoryDataset add
public void add(BoxAndWhiskerItem item, Comparable rowKey, Comparable columnKey)
From source file:GeMSE.Visualization.BoxAndWhiskerPlot.java
private BoxAndWhiskerCategoryDataset CreateDataset() { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); double[][] input = _space.GetContent(true); if (RowsCategoryRB.isSelected()) { for (int r = 0; r < _space.rowsID.length; r++) { ArrayList<Double> list = new ArrayList(); for (int c = 0; c < _space.colsID.length; c++) list.add(input[r][c]);/*from ww w . ja va 2s. c o m*/ dataset.add(list, "Series ", _space.rowTitle[r]); } } else { for (int c = 0; c < _space.colsID.length; c++) { ArrayList<Double> list = new ArrayList(); for (int r = 0; r < _space.rowsID.length; r++) list.add(input[r][c]); dataset.add(list, "Series ", _space.colTitle[c]); } } return dataset; }
From source file:umontreal.iro.lecuyer.charts.BoxSeriesCollection.java
/** * Adds a data series into the series collection. Vector <TT>data</TT> represents * a point set. Only <SPAN CLASS="textit">the first</SPAN> <TT>numPoints</TT> of * <TT>data</TT> will be added to the new series. * /* ww w. j a v a2 s .c o m*/ * @param data Point set * * @param numPoints Number of points to add * * @return Integer that represent the new point set's position in the JFreeChart <TT>DefaultBoxAndWhiskerXYDataset</TT> object. * */ public int add(double[] data, int numPoints) { DefaultBoxAndWhiskerCategoryDataset tempSeriesCollection = (DefaultBoxAndWhiskerCategoryDataset) seriesCollection; final List<Double> list = new ArrayList<Double>(); for (int i = 0; i < numPoints; i++) list.add(data[i]); int count = tempSeriesCollection.getColumnCount(); tempSeriesCollection.add(list, 0, "Serie " + count); return count; }
From source file:edu.ucla.stat.SOCR.chart.demo.DotChart.java
protected BoxAndWhiskerCategoryDataset createDataset2(boolean isDemo) { if (isDemo) { SERIES_COUNT = 1;//w w w . ja va 2 s .c o m CATEGORY_COUNT = 1; VALUE_COUNT = 20; values_storage = new String[SERIES_COUNT][CATEGORY_COUNT]; DefaultBoxAndWhiskerCategoryDataset result = new DefaultBoxAndWhiskerCategoryDataset(); List values = createValueList("3, -2, 4, 4, 5, 6, 6, 7, 1, 1, 1, 2,3, 4, 3, 4, 3, 10, 7, 6"); result.add(values, "", ""); values_storage[0][0] = "3, -2, 4, 4, 5, 6, 6, 7, 1, 1, 1, 2,3, 4, 3, 4, 3, 10, 7, 6"; return result; } else return super.createDataset2(false); }
From source file:fr.ens.transcriptome.corsen.gui.qt.ResultGraphs.java
/** * Create a boxplot./*from www .j ava2 s . c o m*/ * @param results Results to use * @return a QImage */ public QImage createBoxPlot(final CorsenResult results, final String unit) { this.width = this.width / 2; Map<Particle3D, Distance> distsMin = results.getMinDistances(); Map<Particle3D, Distance> distsMax = results.getMaxDistances(); if (distsMin == null || distsMax == null) return null; List<Float> listMin = new ArrayList<Float>(); List<Float> listMax = new ArrayList<Float>(); for (Map.Entry<Particle3D, Distance> e : distsMin.entrySet()) { final Particle3D p = e.getKey(); final long intensity = p.getIntensity(); final float distanceMin = e.getValue().getDistance(); final float distanceMax = distsMax.get(p).getDistance(); for (int i = 0; i < intensity; i++) { listMin.add(distanceMin); listMax.add(distanceMax); } } DefaultBoxAndWhiskerCategoryDataset defaultboxandwhiskercategorydataset = new DefaultBoxAndWhiskerCategoryDataset(); if (results.getMinAnalyser().count() > 0) defaultboxandwhiskercategorydataset .add(convertDistanceAnalyserToBoxAndWhiskerItem(results.getMinAnalyser()), "Distances", "Min"); // defaultboxandwhiskercategorydataset.add(listMin, "Distances", "Min"); // defaultboxandwhiskercategorydataset.add(listMax, "Distances", "Max"); JFreeChart chart = ChartFactory.createBoxAndWhiskerChart("Intensities Boxplot", "", "Distance" + unitLegend(unit), defaultboxandwhiskercategorydataset, false); addTransparency(chart); // CategoryPlot categoryplot = (CategoryPlot) chart.getPlot(); // // chart.setBackgroundPaint(Color.white); // categoryplot.setBackgroundPaint(Color.lightGray); // categoryplot.setDomainGridlinePaint(Color.white); // categoryplot.setDomainGridlinesVisible(true); // categoryplot.setRangeGridlinePaint(Color.white); // // NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); // numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); final BufferedImage image = chart.createBufferedImage(this.width, this.height, BufferedImage.TYPE_INT_ARGB, null); return new QImage(toByte(image.getData().getDataBuffer()), this.width, this.height, QImage.Format.Format_ARGB32); }
From source file:adapters.BoxSeriesCollectionAdapter.java
/** * Modified Method: change label from serie to Cluster plus the number of instances in the cluster * * Adds a data series into the series collection. Vector <TT>data</TT> represents * a point set. Only <SPAN CLASS="textit">the first</SPAN> <TT>numPoints</TT> of * <TT>data</TT> will be added to the new series. * * @param data Point set/*from www.ja va 2 s . co m*/ * * @param numPoints Number of points to add * * @return Integer that represent the new point set's position in the JFreeChart <TT>DefaultBoxAndWhiskerXYDataset</TT> object. * */ public int add(double[] data, int numPoints) { DefaultBoxAndWhiskerCategoryDataset tempSeriesCollection = (DefaultBoxAndWhiskerCategoryDataset) seriesCollection; final List<Double> list = new ArrayList<Double>(); for (int i = 0; i < numPoints; i++) list.add(data[i]); int count = tempSeriesCollection.getColumnCount(); // "count + 1" since the cluster label should start with 1 instead of 0 tempSeriesCollection.add(list, 0, "[ " + numPoints + " ]"); return count; }
From source file:unalcol.termites.boxplots.BestAgentsPercentageInfoCollected.java
private BoxAndWhiskerCategoryDataset addDataSet(Hashtable<String, List> info) { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); for (String key : info.keySet()) { System.out.println(key + ":" + info.get(key).size()); String[] keyData = key.split(Pattern.quote("+")); dataset.add(info.get(key), keyData[1], getTechniqueName(keyData[0])); }/* w w w. jav a2s .c om*/ //System.out.println("dataset" + dataset); return dataset; }
From source file:jp.ac.tohoku.ecei.sb.metabolome.lims.gui.MainWindowController.java
public JFreeChart getChartForPlate(PlateImpl plate) { IntensityMatrixImpl intensityMatrix = dataManager.getIntensityMatrix(); List<Injection> injections = intensityMatrix.getInjectionsByPlate().get(plate); DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); for (Injection one : injections) { dataset.add(Arrays.asList(intensityMatrix.getColumn(one)).stream().map((o) -> ((Double) o)) .collect(Collectors.toList()), "Intensity", one.toString()); }/*from ww w .ja v a2s. co m*/ JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(plate.toString(), "Injection", "Intensity", dataset, true); chart.getCategoryPlot().getDomainAxis() .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2)); return chart; }
From source file:jp.ac.tohoku.ecei.sb.metabolome.lims.gui.MainWindowController.java
public JFreeChart getChartForGlobalQC() { IntensityMatrixImpl intensityMatrix = dataManager.getIntensityMatrix(); if (intensityMatrix == null) return null; List<Sample> globalQCList = intensityMatrix.getGlobalQCSamples(); log.info("global QC {}", globalQCList.size()); if (globalQCList.size() == 0) return null; List<Injection> injections = intensityMatrix.getInjectionsBySample(globalQCList.get(0)); DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); for (Injection one : injections) { dataset.add(Arrays.asList(intensityMatrix.getColumn(one)).stream().map((o) -> ((Double) o)) .collect(Collectors.toList()), "Intensity", one.toString()); }// ww w . j av a2s . c o m JFreeChart chart = ChartFactory.createBoxAndWhiskerChart("Global QC " + globalQCList.get(0).toString(), "Injection", "Intensity", dataset, true); chart.getCategoryPlot().getDomainAxis() .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2)); return chart; }
From source file:de.hs.mannheim.modUro.controller.diagram.BoxAndWhiskerPlotController.java
/** * Creates dataset for BoxWhiskerPlot.// w w w . jav a 2 s . com * * @return */ private BoxAndWhiskerCategoryDataset createDataset() { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); List<String> sortedModels = new ArrayList<>(models); sortedModels.sort(String::compareTo); for (String model : sortedModels) { StatisticValues stat = stats.get(model); BoxAndWhiskerItem item = new BoxAndWhiskerItem(stat.getMean(), stat.getSecondPercentile(), stat.getFirstPercentile(), stat.getLastPercentile(), stat.getMin(), stat.getMax(), stat.getMin(), stat.getMax(), new ArrayList<>()); // Second parameter is the row key (?), using always the same works: dataset.add(item, "", model); } return dataset; }
From source file:umontreal.iro.lecuyer.charts.BoxSeriesCollection.java
/** * Creates a new <TT>BoxSeriesCollection</TT> instance with default * parameters and given data series. The input parameter represents series * of point sets.//w w w . j av a2s. co m * * @param data series of point sets. * * */ public BoxSeriesCollection(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]); tempSeriesCollection.add(list, 0, "Serie " + i); list.clear(); } ((BoxAndWhiskerRenderer) renderer).setMaximumBarWidth(BARWIDTH); }