Example usage for org.jfree.chart ChartFactory createBoxAndWhiskerChart

List of usage examples for org.jfree.chart ChartFactory createBoxAndWhiskerChart

Introduction

In this page you can find the example usage for org.jfree.chart ChartFactory createBoxAndWhiskerChart.

Prototype

public static JFreeChart createBoxAndWhiskerChart(String title, String timeAxisLabel, String valueAxisLabel,
        BoxAndWhiskerXYDataset dataset, boolean legend) 

Source Link

Document

Creates and returns a default instance of a box and whisker chart.

Usage

From source file:playground.wrashid.tryouts.mess.Boxplot.java

/**
 * @param args/*from  ww w.  j a  va2 s .c  om*/
 */
public static void main(String[] args) {

    final BoxAndWhiskerCategoryDataset dataset = createSampleDataset();

    final CategoryAxis xAxis = new CategoryAxis("Type");
    final NumberAxis yAxis = new NumberAxis("Value");
    yAxis.setAutoRangeIncludesZero(false);
    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);
    renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
    final JFreeChart chart = ChartFactory.createBoxAndWhiskerChart("Box-and-Whisker Demo", "x", "y", dataset,
            true);
    final ChartPanel chartPanel = new ChartPanel(chart);

    int width = 500;
    int height = 300;

    try {
        ChartUtilities.saveChartAsPNG(new File("boxPlot.png"), chart, width, height);
    } catch (IOException e) {

    }

}

From source file:org.jfree.chart.demo.BoxAndWhiskerChartDemo1.java

private static JFreeChart createChart(BoxAndWhiskerCategoryDataset boxandwhiskercategorydataset) {
    JFreeChart jfreechart = ChartFactory.createBoxAndWhiskerChart("Box and Whisker Chart Demo 1", "Category",
            "Value", boxandwhiskercategorydataset, true);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    jfreechart.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());
    return jfreechart;
}

From source file:com.thecoderscorner.groovychart.chart.BoxAndWhiskerChart.java

public JFreeChart createChart() {
    JFreeChart chart;/*from  ww w .j a  v  a  2  s . c o  m*/
    if (getDataset() instanceof BoxAndWhiskerXYDataset) {
        chart = ChartFactory.createBoxAndWhiskerChart(getTitle(), getTimeAxisLabel(), getValueAxisLabel(),
                (BoxAndWhiskerXYDataset) getDataset(), isLegend());
    } else {
        chart = ChartFactory.createBoxAndWhiskerChart(getTitle(), getTimeAxisLabel(), getValueAxisLabel(),
                (BoxAndWhiskerCategoryDataset) getDataset(), isLegend());
    }
    return setExtraProperties(chart);
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.boxcharts.SimpleBox.java

public JFreeChart createChart(DatasetMap datasetMap) {

    BoxAndWhiskerCategoryDataset dataset = (BoxAndWhiskerCategoryDataset) datasetMap.getDatasets().get("1");

    JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(name, categoryLabel, valueLabel, dataset, false);

    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);/* ww w  .  j a  va  2  s . co m*/
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
    }

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    BoxAndWhiskerRenderer renderer = (BoxAndWhiskerRenderer) plot.getRenderer();
    chart.setBackgroundPaint(Color.white);

    plot.setBackgroundPaint(new Color(Integer.decode("#c0c0c0").intValue()));
    plot.setDomainGridlinePaint(Color.WHITE);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);
    renderer.setFillBox(true);
    renderer.setArtifactPaint(Color.BLACK);
    renderer.setSeriesPaint(0, new Color(Integer.decode("#0000FF").intValue()));

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setRange(min, max);

    return chart;
}

From source file:jmbench.plots.SummaryWhiskerPlot.java

public JFreeChart createChart() {
    JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(title, "Matrix Libraries", "Relative Performance",
            dataSet, true);/*from  www.  ja va  2  s  .  c om*/
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setDomainGridlinesVisible(true);
    plot.setBackgroundPaint(new Color(230, 230, 230));
    plot.setDomainGridlinePaint(new Color(50, 50, 50, 50));
    plot.setDomainGridlineStroke(new BasicStroke(78f));

    chart.getTitle().setFont(new Font("Times New Roman", Font.BOLD, 24));

    String foo = "( Higher is Better )";
    if (subtitle != null)
        foo += "      ( " + subtitle + " )";

    chart.addSubtitle(new TextTitle(foo, new Font("SansSerif", Font.ITALIC, 12)));

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    return chart;
}

From source file:org.jfree.chart.demo.XYBoxAndWhiskerDemo.java

/**
 * Creates a chart.//from  w w w .j  ava 2s. co m
 * 
 * @param dataset  the dataset.
 * 
 * @return The dataset.
 */
private JFreeChart createChart(final BoxAndWhiskerXYDataset dataset) {

    final JFreeChart chart = ChartFactory.createBoxAndWhiskerChart("Box-and-Whisker Demo", "Time", "Value",
            dataset, true);
    XYPlot plot = (XYPlot) chart.getPlot();
    XYBoxAndWhiskerRenderer renderer = (XYBoxAndWhiskerRenderer) plot.getRenderer();
    renderer.setFillBox(false);
    return chart;

}

From source file:umontreal.iro.lecuyer.charts.BoxChart.java

protected void init(String title, String XLabel, String YLabel) {
    // create the chart...
    chart = ChartFactory.createBoxAndWhiskerChart(title, // chart title
            XLabel, // x axis label
            YLabel, // y axis label
            (DefaultBoxAndWhiskerCategoryDataset) dataset.getSeriesCollection(), // data
            true // include legend
    );/*from  ww  w  . j av  a 2s.co  m*/

    ((CategoryPlot) chart.getPlot()).setRenderer(dataset.getRenderer());
    // Initialize axis variables
    initAxis();
}

From source file:org.jax.bham.test.PhenotypeEffectPlotPanel.java

private void updateChart() {
    BoxAndWhiskerCategoryDataset dataset = this.createDataset();
    JFreeChart chart = ChartFactory.createBoxAndWhiskerChart("Phenotype Effect Plot", "Groups",
            this.phenotypeDataSource.getName(), dataset, true);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    BoxAndWhiskerRenderer renderer = (BoxAndWhiskerRenderer) plot.getRenderer();
    renderer.setMaximumBarWidth(0.05);/*from w w  w .j av a2 s.c o m*/

    this.chartPanel.setChart(chart);
}

From source file:br.upe.ecomp.dosa.controller.chart.FileBoxplotChartManager.java

private JFreeChart createChart(String title, String xLabel, String yLabel, BoxAndWhiskerCategoryDataset dataset,
        boolean logarithmicYAxis) {

    final CategoryAxis xAxis = new CategoryAxis("Sample");
    final NumberAxis yAxis;
    if (logarithmicYAxis) {
        yAxis = new LogarithmicAxis("Fitness (Log10)");
        ((LogarithmicAxis) yAxis).setExpTickLabelsFlag(true);
    } else {//from  w  ww .  ja  v a 2 s. co m
        yAxis = new NumberAxis("Fitness");
    }
    yAxis.setAutoRangeIncludesZero(false);
    yAxis.setAutoRange(true);
    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(true);
    renderer.setBaseCreateEntities(true);
    // renderer.setArtifactPaint(Color.green);
    renderer.setBaseOutlinePaint(Color.blue);
    renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    final JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(title, xAxis.getLabel(), yAxis.getLabel(),
            dataset, true);
    final CategoryPlot plot = chart.getCategoryPlot();// new CategoryPlot(dataset, xAxis, yAxis,
                                                      // renderer);
    plot.setBackgroundPaint(Color.white);
    // chart.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setRenderer(renderer);
    plot.setRangeAxis(yAxis);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    return chart;
}

From source file:playground.thibautd.utils.charts.TwoCategoriesBoxAndWhiskerChart.java

private void createChart() {
    this.chart = ChartFactory.createBoxAndWhiskerChart(chartTitle, xAxisLabel, yAxisLabel, dataset, true); // legend?

    if (plotStdDev) {
        CategoryPlot plot = chart.getCategoryPlot();
        // StatisticalLineAndShapeRenderer renderer =
        //       new StatisticalLineAndShapeRenderer(
        //          false,  // lines from average to average
        //          false ); // shapes 
        StatisticalBarRenderer renderer = new NoLegendStatisticalBarRenderer();
        // do not draw bars
        renderer.setDrawBarOutline(false);
        renderer.setShadowVisible(false);
        renderer.setBasePaint(new Color(0, 0, 0, 0));
        renderer.setAutoPopulateSeriesPaint(false);
        // draw all error bars in black
        renderer.setErrorIndicatorPaint(Color.BLACK);
        plot.setRenderer(1, // index
                renderer);//from w w w . j  a v  a2  s .c om
        plot.setDataset(1, errorBarsDataset);
        plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    }

    this.addDefaultFormatting();
}