Example usage for org.jfree.chart.axis NumberAxis setAutoRangeIncludesZero

List of usage examples for org.jfree.chart.axis NumberAxis setAutoRangeIncludesZero

Introduction

In this page you can find the example usage for org.jfree.chart.axis NumberAxis setAutoRangeIncludesZero.

Prototype

public void setAutoRangeIncludesZero(boolean flag) 

Source Link

Document

Sets the flag that indicates whether or not the axis range, if automatically calculated, is forced to include zero.

Usage

From source file:visualizer.datamining.dataanalysis.NeighborhoodHit.java

private JFreeChart createChart(XYDataset xydataset) {
    JFreeChart chart = ChartFactory.createXYLineChart("Neighborhood Hit", "Number Neighbors", "Precision",
            xydataset, PlotOrientation.VERTICAL, true, true, false);

    chart.setBackgroundPaint(Color.WHITE);

    XYPlot xyplot = (XYPlot) chart.getPlot();
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setAutoRangeIncludesZero(false);

    xyplot.setDomainGridlinePaint(Color.BLACK);
    xyplot.setRangeGridlinePaint(Color.BLACK);

    xyplot.setOutlinePaint(Color.BLACK);
    xyplot.setOutlineStroke(new BasicStroke(1.0f));
    xyplot.setBackgroundPaint(Color.white);
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);

    xyplot.setDrawingSupplier(new DefaultDrawingSupplier(
            new Paint[] { Color.RED, Color.BLUE, Color.GREEN, Color.MAGENTA, Color.CYAN, Color.ORANGE,
                    Color.BLACK, Color.DARK_GRAY, Color.GRAY, Color.LIGHT_GRAY, Color.YELLOW },
            DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));

    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    xylineandshaperenderer.setBaseShapesVisible(true);
    xylineandshaperenderer.setBaseShapesFilled(true);
    xylineandshaperenderer.setDrawOutlines(true);

    return chart;
}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.explore.EnclosingBallController.java

public void plotXTBalls(TrackDataHolder trackDataHolder) {
    int selectedIndexEpsilon = exploreTrackController.getExploreTrackPanel().getEnclosingBallEpsCombobox()
            .getSelectedIndex();//from www .j  a v  a2s.  com
    List<List<EnclosingBall>> xtEnclosingBallList = trackDataHolder.getStepCentricDataHolder()
            .getxTEnclosingBalls();
    List<EnclosingBall> xTempBalls = xtEnclosingBallList.get(selectedIndexEpsilon);
    // get the track coordinates matrix and transpose it
    Double[][] transpose2DArray = AnalysisUtils
            .transpose2DArray(trackDataHolder.getStepCentricDataHolder().getCoordinatesMatrix());
    // we get the x coordinates and the time information
    double[] xCoordinates = ArrayUtils.toPrimitive(AnalysisUtils.excludeNullValues(transpose2DArray[0]));
    double[] timeIndexes = trackDataHolder.getStepCentricDataHolder().getTimeIndexes();
    // we create the series and set its key
    XYSeries xtSeries = JFreeChartUtils.generateXYSeries(timeIndexes, xCoordinates);
    String seriesKey = "track " + trackDataHolder.getTrack().getTrackNumber() + ", well "
            + trackDataHolder.getTrack().getWellHasImagingType().getWell();
    xtSeries.setKey(seriesKey);
    // we then create the XYSeriesCollection and use it to make a new line chart
    XYSeriesCollection xtSeriesCollection = new XYSeriesCollection(xtSeries);
    JFreeChart chart = ChartFactory.createXYLineChart(seriesKey + " - enclosing balls", "time", "x (m)",
            xtSeriesCollection, PlotOrientation.VERTICAL, false, true, false);
    XYPlot xyPlot = chart.getXYPlot();
    xyPlot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    NumberAxis yaxis = (NumberAxis) xyPlot.getRangeAxis();
    yaxis.setAutoRangeIncludesZero(false);
    JFreeChartUtils.setupXYPlot(xyPlot);
    JFreeChartUtils.setupSingleTrackPlot(chart,
            exploreTrackController.getExploreTrackPanel().getTracksList().getSelectedIndex(), true);
    xTBallsChartPanel.setChart(chart);
    xTempBalls.stream().forEach((ball) -> {
        xyPlot.addAnnotation(new XYShapeAnnotation(ball.getShape(), JFreeChartUtils.getDashedLine(),
                GuiUtils.getDefaultColor()));
    });
}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.explore.EnclosingBallController.java

public void plotYTBalls(TrackDataHolder trackDataHolder) {
    int selectedIndexEpsilon = exploreTrackController.getExploreTrackPanel().getEnclosingBallEpsCombobox()
            .getSelectedIndex();/*from  w  w w  .  j  ava2 s.c  o  m*/
    List<List<EnclosingBall>> ytEnclosingBallList = trackDataHolder.getStepCentricDataHolder()
            .getyTEnclosingBalls();
    List<EnclosingBall> yTempBalls = ytEnclosingBallList.get(selectedIndexEpsilon);
    // get the track coordinates matrix and transpose it
    Double[][] transpose2DArray = AnalysisUtils
            .transpose2DArray(trackDataHolder.getStepCentricDataHolder().getCoordinatesMatrix());
    // we get the y coordinates and the time information
    double[] yCoordinates = ArrayUtils.toPrimitive(AnalysisUtils.excludeNullValues(transpose2DArray[1]));
    double[] timeIndexes = trackDataHolder.getStepCentricDataHolder().getTimeIndexes();
    // we create the series and set its key
    XYSeries ytSeries = JFreeChartUtils.generateXYSeries(timeIndexes, yCoordinates);
    String seriesKey = "track " + trackDataHolder.getTrack().getTrackNumber() + ", well "
            + trackDataHolder.getTrack().getWellHasImagingType().getWell();
    ytSeries.setKey(seriesKey);
    // we then create the XYSeriesCollection and use it to make a new line chart
    XYSeriesCollection ytSeriesCollection = new XYSeriesCollection(ytSeries);
    JFreeChart chart = ChartFactory.createXYLineChart(seriesKey + " - enclosing balls", "time", "y (m)",
            ytSeriesCollection, PlotOrientation.VERTICAL, false, true, false);
    XYPlot xyPlot = chart.getXYPlot();
    xyPlot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    NumberAxis yaxis = (NumberAxis) xyPlot.getRangeAxis();
    yaxis.setAutoRangeIncludesZero(false);
    JFreeChartUtils.setupXYPlot(xyPlot);
    JFreeChartUtils.setupSingleTrackPlot(chart,
            exploreTrackController.getExploreTrackPanel().getTracksList().getSelectedIndex(), true);
    yTBallsChartPanel.setChart(chart);
    yTempBalls.stream().forEach((ball) -> {
        xyPlot.addAnnotation(new XYShapeAnnotation(ball.getShape(), JFreeChartUtils.getDashedLine(),
                GuiUtils.getDefaultColor()));
    });
}

From source file:unalcol.termites.boxplots.ECALAgentsRight.java

/**
 * Creates a new demo./*w  w w. j  a  v a 2 s  . co  m*/
 *
 * @param title the frame title.
 * @param pf
 */
public ECALAgentsRight(final String title, ArrayList<Double> pf) {

    super(title);

    final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(pf);

    final CategoryAxis xAxis = new CategoryAxis("");
    //        final NumberAxis yAxis = new NumberAxis("Round number");
    final NumberAxis yAxis = new NumberAxis("");

    yAxis.setAutoRangeIncludesZero(false);
    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);
    renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    Font font = new Font("Dialog", Font.PLAIN, 13);
    xAxis.setTickLabelFont(font);
    yAxis.setTickLabelFont(font);
    yAxis.setLabelFont(font);

    final JFreeChart chart = new JFreeChart("Agents Right " + getTitle(pf),
            new Font("SansSerif", Font.BOLD, 18), plot, true);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(650, 370));
    setContentPane(chartPanel);
    TextTitle legendText = null;
    if (pf.size() == 1) {
        legendText = new TextTitle("Population Size");
    } else {
        legendText = new TextTitle("Population Size - Probability of Failure");
    }

    legendText.setFont(font);
    legendText.setPosition(RectangleEdge.BOTTOM);
    chart.addSubtitle(legendText);
    chart.getLegend().setItemFont(font);

    FileOutputStream output;
    try {
        output = new FileOutputStream("ECALright" + pf + ".jpg");
        ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 400, 400, null);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(ECALAgentsRight.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(ECALAgentsRight.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:unalcol.termites.boxplots.ECALRoundNumber.java

/**
 * Creates a new demo.//from w ww  .ja v a2  s .c  o  m
 *
 * @param title the frame title.
 * @param pf
 */
public ECALRoundNumber(final String title, ArrayList<Double> pf) {

    super(title);

    final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(pf);

    final CategoryAxis xAxis = new CategoryAxis("");
    //        final NumberAxis yAxis = new NumberAxis("Round number");
    final NumberAxis yAxis = new NumberAxis("");

    yAxis.setAutoRangeIncludesZero(false);
    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);
    renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    Font font = new Font("Dialog", Font.PLAIN, 13);
    xAxis.setTickLabelFont(font);
    yAxis.setTickLabelFont(font);
    yAxis.setLabelFont(font);

    final JFreeChart chart = new JFreeChart("Round Number " + getTitle(pf),
            new Font("SansSerif", Font.BOLD, 18), plot, true);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(650, 370));
    setContentPane(chartPanel);
    TextTitle legendText = null;
    if (pf.size() == 1) {
        legendText = new TextTitle("Population Size");
    } else {
        legendText = new TextTitle("Population Size - Probability of Failure");
    }

    legendText.setFont(font);
    legendText.setPosition(RectangleEdge.BOTTOM);
    chart.addSubtitle(legendText);
    chart.getLegend().setItemFont(font);

    FileOutputStream output;
    try {
        output = new FileOutputStream("ECALround" + pf + ".jpg");
        ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 400, 400, null);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(ECALRoundNumber.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(ECALRoundNumber.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:keel.Algorithms.UnsupervisedLearning.AssociationRules.Visualization.keelassotiationrulesboxplot.ResultsProccessor.java

public void writeToFile(String outName)
        throws FileNotFoundException, UnsupportedEncodingException, IOException {
    //calcMeans();

    // Create JFreeChart Dataset
    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();

    HashMap<String, ArrayList<Double>> measuresFirst = algorithmMeasures.entrySet().iterator().next()
            .getValue();/* w  w w.  j  a va  2s  . c  om*/
    for (Map.Entry<String, ArrayList<Double>> measure : measuresFirst.entrySet()) {
        String measureName = measure.getKey();
        //Double measureValue = measure.getValue();
        dataset.clear();

        for (Map.Entry<String, HashMap<String, ArrayList<Double>>> entry : algorithmMeasures.entrySet()) {
            String alg = entry.getKey();
            ArrayList<Double> measureValues = entry.getValue().get(measureName);

            // Parse algorithm name to show it correctly
            String aName = alg.substring(0, alg.length() - 1);
            int startAlgName = aName.lastIndexOf("/");
            aName = aName.substring(startAlgName + 1);

            dataset.add(measureValues, aName, measureName);
        }

        // Tutorial: http://www.java2s.com/Code/Java/Chart/JFreeChartBoxAndWhiskerDemo.htm
        final CategoryAxis xAxis = new CategoryAxis("Algorithm");
        final NumberAxis yAxis = new NumberAxis("Value");
        yAxis.setAutoRangeIncludesZero(false);
        final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();

        // Black and White
        int numItems = algorithmMeasures.size();
        for (int i = 0; i < numItems; i++) {
            Color color = Color.DARK_GRAY;
            if (i % 2 == 1) {
                color = Color.LIGHT_GRAY;
            }
            renderer.setSeriesPaint(i, color);
            renderer.setSeriesOutlinePaint(i, Color.BLACK);
        }

        renderer.setMeanVisible(false);
        renderer.setFillBox(false);
        renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
        final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

        Font font = new Font("SansSerif", Font.BOLD, 10);
        //ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
        JFreeChart jchart = new JFreeChart("Assotiation Rules Measures - BoxPlot", font, plot, true);
        //StandardChartTheme.createLegacyTheme().apply(jchart);

        int width = 640 * 2; /* Width of the image */
        int height = 480 * 2; /* Height of the image */

        // JPEG
        File chart = new File(outName + "_" + measureName + "_boxplot.jpg");
        ChartUtilities.saveChartAsJPEG(chart, jchart, width, height);

        // SVG
        SVGGraphics2D g2 = new SVGGraphics2D(width, height);
        Rectangle r = new Rectangle(0, 0, width, height);
        jchart.draw(g2, r);
        File BarChartSVG = new File(outName + "_" + measureName + "_boxplot.svg");
        SVGUtils.writeToSVG(BarChartSVG, g2.getSVGElement());
    }

}

From source file:unalcol.termites.boxplots.RoundNumber2.java

/**
 * Creates a new demo./*from  ww  w.  j a  v a 2s .  c o m*/
 *
 * @param title the frame title.
 * @param pf
 */
public RoundNumber2(final String title, ArrayList<Double> pf) {

    super(title);

    final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(pf);

    final CategoryAxis xAxis = new CategoryAxis("");
    //        final NumberAxis yAxis = new NumberAxis("Round number");
    final NumberAxis yAxis = new NumberAxis("");

    yAxis.setAutoRangeIncludesZero(false);
    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);
    renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    Font font = new Font("Dialog", Font.PLAIN, 13);
    xAxis.setTickLabelFont(font);
    yAxis.setTickLabelFont(font);
    yAxis.setLabelFont(font);

    final JFreeChart chart = new JFreeChart("Round Number " + getTitle(pf),
            new Font("SansSerif", Font.BOLD, 18), plot, true);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(650, 370));
    setContentPane(chartPanel);
    TextTitle legendText = null;
    if (pf.size() == 1) {
        legendText = new TextTitle("Population Size");
    } else {
        legendText = new TextTitle("Population Size - Probability of Failure");
    }

    legendText.setFont(font);
    legendText.setPosition(RectangleEdge.BOTTOM);
    chart.addSubtitle(legendText);
    chart.getLegend().setItemFont(font);

    FileOutputStream output;
    try {
        output = new FileOutputStream("roundnumber2" + pf + ".jpg");
        ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 300, 250, null);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(RoundNumber2.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(RoundNumber2.class.getName()).log(Level.SEVERE, null, ex);
    }

}

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

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

    // create the chart...
    final JFreeChart chart = ChartFactory.createLineChart("", // chart title
            xLabel, // domain axis label
            yLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );/* www. jav  a  2  s .  co m*/

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    // final StandardLegend legend = (StandardLegend) chart.getLegend();
    // legend.setDisplaySeriesShapes(true);
    // legend.setShapeScaleX(1.5);
    // legend.setShapeScaleY(1.5);
    // legend.setDisplaySeriesLines(true);

    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.lightGray);

    // customise the range axis...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(true);
    return chart;
}

From source file:unalcol.termites.boxplots.InformationCollected2.java

/**
 * Creates a new demo./*from w ww .j  av a2s  . c o m*/
 *
 * @param title the frame title.
 * @param pf
 */
public InformationCollected2(final String title, ArrayList<Double> pf) {

    super(title);

    final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(pf);

    final CategoryAxis xAxis = new CategoryAxis("");
    //final NumberAxis yAxis = new NumberAxis("Information Collected");
    final NumberAxis yAxis = new NumberAxis("");

    yAxis.setAutoRangeIncludesZero(false);
    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);
    renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    Font font = new Font("Dialog", Font.PLAIN, 13);
    xAxis.setTickLabelFont(font);
    yAxis.setTickLabelFont(font);
    yAxis.setLabelFont(font);

    final JFreeChart chart = new JFreeChart("Information Collected " + getTitle(pf),
            new Font("SansSerif", Font.BOLD, 18), plot, true);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(650, 370));
    setContentPane(chartPanel);

    TextTitle legendText = null;
    if (pf.size() == 1) {
        legendText = new TextTitle("Population Size");
    } else {
        legendText = new TextTitle("Population Size - Probability of Failure");
    }

    legendText.setFont(font);
    legendText.setPosition(RectangleEdge.BOTTOM);
    chart.addSubtitle(legendText);
    chart.getLegend().setItemFont(font);

    FileOutputStream output;
    try {
        output = new FileOutputStream("informationcollected2" + pf + ".jpg");
        ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 350, 350, null);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(InformationCollected2.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(InformationCollected2.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:org.ietr.preesm.mapper.ui.BestCostPlotter.java

/**
 * Creates a chart.//from  ww  w. ja  v  a2s  . c o  m
 * 
 * @return A chart.
 */
private JFreeChart createChart(String title) {

    final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis("Time"));
    this.datasets = new TimeSeriesCollection[subplotCount];

    for (int i = 0; i < subplotCount; i++) {
        this.lastValue[i] = 100.0;
        final TimeSeries series = new TimeSeries("Real Time", Millisecond.class);
        this.datasets[i] = new TimeSeriesCollection(series);
        final NumberAxis rangeAxis = new NumberAxis("Schedule");
        rangeAxis.setAutoRangeIncludesZero(false);
        final XYPlot subplot = new XYPlot(this.datasets[i], null, rangeAxis, new XYLineAndShapeRenderer());

        subplot.setBackgroundPaint(Color.white);
        subplot.setDomainGridlinePaint(Color.lightGray);
        subplot.setRangeGridlinePaint(Color.lightGray);
        plot.add(subplot);
    }

    final JFreeChart chart = new JFreeChart(title, plot);

    chart.removeLegend();
    // chart.getLegend().setPosition(RectangleEdge.BOTTOM);

    chart.setBorderPaint(Color.lightGray);
    chart.setBorderVisible(true);

    Paint p = GanttPlotter.getBackgroundColorGradient();
    chart.setBackgroundPaint(p);

    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.black);

    final ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);

    return chart;

}