Examples of DefaultBoxAndWhiskerCategoryDataset


Examples of org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset

   
    }
   
    public void createPlot(String plotTitle, File outdir) throws IOException{
        XYSeriesCollection dataset = new XYSeriesCollection();
        DefaultBoxAndWhiskerCategoryDataset scatterDataset = new DefaultBoxAndWhiskerCategoryDataset();

        PrintStream boxchart_dataStream = new PrintStream(new File(outdir, plotTitle + ".boxchart.txt"));
       
        boxchart_dataStream.println("#\tkmer" + "\trank" + "\t" + "max" + "\t" + "avg" + "\t" + "min" +
                "\t" + "Q1" + "\t" + "median" + "\t" + "Q3" + "\t" + "98Pct" + "\t" + "2Pct" + "\t" + "comparisons" + "\t" + "sum");
        for ( int i = 0; i < ranks.size(); i++){
            long[] countArray = sabCoutMap.get(ranks.get(i));
            if ( countArray == null) continue;
           
            double sum = 0.0;
            int max = 0;
            int min = 100;
            double mean = 0;
            int Q1 = -1;
            int median = -1;
            int Q3 = -1;
            int pct_98 =-1;
            int pct_2 = -1;
            long comparisons = 0;
            int minOutlier = 0// we don't care about the outliers
            int maxOutlier = 0//
           
            XYSeries series = new XYSeries(ranks.get(i));
           
            for ( int c = 0; c< countArray.length; c++){
                if ( countArray[c] == 0 ) continue;
                comparisons += countArray[c];
                sum += countArray[c] * c;
                if ( c < min){
                    min = c;
                }
                if ( c > max){
                    max = c;
                }
            }
           
            // create series
            double cum = 0;
            for ( int c = 0; c< countArray.length; c++){
                if ( countArray[c] == 0 ) continue;
                cum += countArray[c];
                int pct = (int) Math.floor(100*cum/comparisons);
                series.add(c, pct);
               
                if ( pct_2 == -1 && pct >=5){
                    pct_2 = c;
                }
                if ( Q3 == -1 && pct >=25){
                    Q3 = c;
                }
                if ( median == -1 && pct >=50){
                    median = c;
                }
                if ( Q1 == -1 && pct >=75){
                    Q1 = c;
                }
                if ( pct_98 == -1 && pct >=98){
                    pct_98 = c;
                }
            }
            if ( !series.isEmpty()) {
                dataset.addSeries(series);
               
                BoxAndWhiskerItem item = new BoxAndWhiskerItem(sum/comparisons, median, Q1, Q3, pct_2, pct_98,  minOutlier,  maxOutlier, new ArrayList());
                scatterDataset.add(item, ranks.get(i), "");
               
                boxchart_dataStream.println("#\t" + GoodWordIterator.getWordsize() + "\t" + ranks.get(i) + "\t" + max + "\t" + format.format(sum/comparisons) + "\t" + min +
                "\t" + Q1 + "\t" + median + "\t" + Q3 + "\t" + pct_98 + "\t" + pct_2 + "\t" + comparisons + "\t" + sum);
            }
        } 
View Full Code Here

Examples of org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset

*/
public class BoxPlotUtils {
   
    public static void readData(String inFile, File outdir, String xAxisLabel, String yAxisLabel) throws IOException{
        XYSeriesCollection dataset = new XYSeriesCollection();
        DefaultBoxAndWhiskerCategoryDataset scatterDataset = new DefaultBoxAndWhiskerCategoryDataset();

        BufferedReader reader = new BufferedReader(new FileReader(inFile));
        String line = reader.readLine();
       
        while ( (line = reader.readLine()) != null){
            String[] values = line.split("\\t");
            XYSeries series = new XYSeries(values[2]);
            dataset.addSeries(series);
               
            double average = Double.parseDouble(values[4]);
            int Q1 = Integer.parseInt(values[6]);;
            int median = Integer.parseInt(values[7]);
            int Q3 = Integer.parseInt(values[8]);
            int pct_98 = Integer.parseInt(values[9]);
            int pct_2 = Integer.parseInt(values[10]);
            int minOutlier = 0// we don't care about the outliers
            int maxOutlier = 0//
           
            BoxAndWhiskerItem item = new BoxAndWhiskerItem(average, median, Q1, Q3, pct_2, pct_98,  minOutlier,  maxOutlier, new ArrayList());
            scatterDataset.add(item, values[2], "");
        }
       
        String title = new File(inFile).getName();
        int index = title.indexOf(".");
View Full Code Here

Examples of org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset

     */
    public static JFreeChart buildBoxPlot(final Number[] numbers, final String dataName) {
        if (numbers == null || numbers.length == 0) {
            return null;
        }
        DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
        final ArrayList<Number> list = new ArrayList<Number>();
        list.addAll(Arrays.asList(numbers));

        final String valuesString = getMessage("ChartsUtils.report.box-plot.values");
        dataset.add(list, valuesString, "");

        final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
        renderer.setMeanVisible(false);
        renderer.setFillBox(false);
        renderer.setMaximumBarWidth(0.5);
View Full Code Here

Examples of org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset

    /**
     * Confirm that the equals method can distinguish all the required fields.
     */
    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));
    }
View Full Code Here

Examples of org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset

    /**
     * Serialize an instance, restore it, and check for equality.
     */
    public void testSerialization() {

        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 = null;

        try {
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
            ObjectOutput out = new ObjectOutputStream(buffer);
            out.writeObject(d1);
View Full Code Here

Examples of org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset

    /**
     * Confirm that cloning works.
     */
    public void testCloning() {
        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 = null;
        try {
            d2 = (DefaultBoxAndWhiskerCategoryDataset) d1.clone();
        }
        catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        assertTrue(d1 != d2);
        assertTrue(d1.getClass() == d2.getClass());
        assertTrue(d1.equals(d2));

        // test independence
        d1.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0),
                new Double(3.0), new Double(4.0), new Double(5.0),
View Full Code Here

Examples of org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset

    /**
     * A simple test for bug report 1701822.
     */
    public void test1701822() {
        DefaultBoxAndWhiskerCategoryDataset dataset
                = new DefaultBoxAndWhiskerCategoryDataset();
        try {
            dataset.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), null, new Double(8.0),
                    new ArrayList()), "ROW1", "COLUMN1");
            dataset.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), null,
                    new ArrayList()), "ROW1", "COLUMN2");
        }
        catch (NullPointerException e) {
View Full Code Here

Examples of org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset

    /**
     * Some checks for the add() method.
     */
    public void testAdd() {
        DefaultBoxAndWhiskerCategoryDataset dataset
                = new DefaultBoxAndWhiskerCategoryDataset();
        BoxAndWhiskerItem item1 = new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0,
                5.0, 6.0, 7.0, 8.0, new ArrayList());
        dataset.add(item1, "R1", "C1");

        assertEquals(2.0, dataset.getValue("R1", "C1").doubleValue(), EPSILON);
        assertEquals(1.0, dataset.getMeanValue("R1", "C1").doubleValue(),
                EPSILON);
        assertEquals(2.0, dataset.getMedianValue("R1", "C1").doubleValue(),
                EPSILON);
        assertEquals(3.0, dataset.getQ1Value("R1", "C1").doubleValue(),
                EPSILON);
        assertEquals(4.0, dataset.getQ3Value("R1", "C1").doubleValue(),
                EPSILON);
        assertEquals(5.0, dataset.getMinRegularValue("R1", "C1").doubleValue(),
                EPSILON);
        assertEquals(6.0, dataset.getMaxRegularValue("R1", "C1").doubleValue(),
                EPSILON);
        assertEquals(7.0, dataset.getMinOutlier("R1", "C1").doubleValue(),
                EPSILON);
        assertEquals(8.0, dataset.getMaxOutlier("R1", "C1").doubleValue(),
                EPSILON);
        assertEquals(new Range(7.0, 8.0), dataset.getRangeBounds(false));
    }
View Full Code Here

Examples of org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset

     * no exceptions are thrown (particularly by code in the renderer).
     */
    public void testDrawWithNullInfo() {
        boolean success = false;
        try {
            DefaultBoxAndWhiskerCategoryDataset dataset
                = new DefaultBoxAndWhiskerCategoryDataset();
            dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0),
                    new Double(0.0), new Double(4.0), new Double(0.5),
                    new Double(4.5), new Double(-0.5), new Double(5.5),
                    null), "S1", "C1");
            CategoryPlot plot = new CategoryPlot(dataset,
                    new CategoryAxis("Category"), new NumberAxis("Value"),
View Full Code Here

Examples of org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset

    /**
     * A check for bug 1572478 (for the vertical orientation).
     */
    public void testBug1572478Vertical() {
        DefaultBoxAndWhiskerCategoryDataset dataset
                = new DefaultBoxAndWhiskerCategoryDataset() {

            public Number getQ1Value(int row, int column) {
                return null;
            }

            public Number getQ1Value(Comparable rowKey, Comparable columnKey) {
                return null;
            }
        };
        List values = new ArrayList();
        values.add(new Double(1.0));
        values.add(new Double(10.0));
        values.add(new Double(100.0));
        dataset.add(values, "row", "column");
        CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"),
                new NumberAxis("y"), new BoxAndWhiskerRenderer());
        JFreeChart chart = new JFreeChart(plot);
        boolean success = false;

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.