Example usage for org.jfree.chart.renderer.xy XYErrorRenderer setDrawXError

List of usage examples for org.jfree.chart.renderer.xy XYErrorRenderer setDrawXError

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.xy XYErrorRenderer setDrawXError.

Prototype

public void setDrawXError(boolean draw) 

Source Link

Document

Sets the flag that controls whether or not the renderer draws error bars for the x-values and, if the flag changes, sends a RendererChangeEvent to all registered listeners.

Usage

From source file:graph.jfreecharts.GraphFunction.java

/**
 * A custom xyerror renderer because jfreecharts does not
 * have it supported in the api.//from  w  w  w . j  a  v  a 2 s .co  m
 * @param title the graph title
 * @param xAxisLabel the xaxis title
 * @param yAxisLabel the yaxis title
 * @param dataset the xydataset
 * @param orientation the plot orientation
 * @param legend true to turn on legend
 * @param tooltips true to turn on tooltips (the pop up when right click)
 * @param urls // no idea what this is for
 * @return
 */
private static JFreeChart createXYIntervalChart(String title, String xAxisLabel, String yAxisLabel,
        XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    XYErrorRenderer renderer = new XYErrorRenderer();

    renderer.setDrawXError(true);
    renderer.setDrawYError(true);

    xAxis.setNumberFormatOverride(new DecimalFormat("0.######E0"));
    yAxis.setNumberFormatOverride(new DecimalFormat("0.######E0"));

    xAxis.setAutoRangeIncludesZero(false);
    yAxis.setAutoRangeIncludesZero(false);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(orientation);
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    currentTheme.apply(chart);
    return chart;

}

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

private void createChart() {
    boolean legend = false;

    this.createDataSet();

    this.chart = ChartFactory.createBoxAndWhiskerChart(this.chartTitle, this.xAxisLabel, this.yAxisLabel,
            this.boxes, legend);

    XYPlot plot = this.chart.getXYPlot();
    plot.setDomainAxis(new NumberAxis(this.xAxisLabel));
    plot.getDomainAxis().configure();/* w ww . j ava  2s  .co m*/

    if (plotStdDev) {
        XYErrorRenderer renderer = new XYErrorRenderer();
        // in black
        renderer.setErrorPaint(Color.BLACK);
        // only plot Y error
        renderer.setDrawXError(false);
        // do not render average (already done by the B&W)
        renderer.setBaseShapesVisible(false);
        plot.setRenderer(1, renderer);
        plot.setDataset(1, deviationBars);
        plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    }

    //this.addMatsimLogo();

    //try {
    //   this.addDefaultFormatting();
    //} catch (NullPointerException e) {
    //   // occurs if no legend
    //}

    //this.chart.setBackgroundPaint(Color.white);
    plot.setBackgroundPaint(Color.white);
    XYBoxAndWhiskerRenderer renderer = (XYBoxAndWhiskerRenderer) plot.getRenderer();
    //renderer.setFillBox(false);
    //renderer.setSeriesOutlinePaint(0, Color.black);
    //renderer.setSeriesPaint(0, Color.black);
    renderer.setBoxPaint(renderer.getSeriesPaint(0));
    //auto-adjust
    renderer.setBoxWidth(-1);
}

From source file:org.esa.beam.timeseries.ui.graph.TimeSeriesGraphModel.java

private XYErrorRenderer createXYErrorRenderer() {
    final XYErrorRenderer renderer = new XYErrorRenderer();
    renderer.setDrawXError(false);
    renderer.setDrawYError(false);//w w w .j av a 2s  .c  o m
    renderer.setBaseLinesVisible(true);
    renderer.setAutoPopulateSeriesStroke(false);
    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setAutoPopulateSeriesFillPaint(false);
    renderer.setAutoPopulateSeriesOutlinePaint(false);
    renderer.setAutoPopulateSeriesOutlineStroke(false);
    renderer.setAutoPopulateSeriesShape(false);
    final StandardXYToolTipGenerator tipGenerator;
    tipGenerator = new StandardXYToolTipGenerator("Value: {2}   Date: {1}", new SimpleDateFormat(),
            new DecimalFormat());
    renderer.setBaseToolTipGenerator(tipGenerator);
    return renderer;
}

From source file:weka.classifiers.timeseries.eval.graph.JFreeChartDriver.java

protected JFreeChart getPredictedTargetsChart(TSForecaster forecaster, ErrorModule preds,
        List<String> targetNames, int stepNumber, int instanceNumOffset, Instances data) {

    if (forecaster instanceof TSLagUser && data != null) {
        TSLagMaker lagMaker = ((TSLagUser) forecaster).getTSLagMaker();
        if (lagMaker.getAdjustForTrends() && !lagMaker.isUsingAnArtificialTimeIndex()) {

            // fill in any missing time stamps only
            data = new Instances(data);
            data = weka.classifiers.timeseries.core.Utils.replaceMissing(data, null,
                    lagMaker.getTimeStampField(), true, lagMaker.getPeriodicity(), lagMaker.getSkipEntries());
        }//from  ww  w .java 2s  . c om
    }

    // set up a collection of predicted and actual series
    XYIntervalSeriesCollection xyDataset = new XYIntervalSeriesCollection();
    for (String target : targetNames) {
        XYIntervalSeries targetSeries = new XYIntervalSeries(target + "-actual", false, false);
        xyDataset.addSeries(targetSeries);
        targetSeries = new XYIntervalSeries(target + "-predicted", false, false);
        xyDataset.addSeries(targetSeries);

    }

    ValueAxis timeAxis = null;
    NumberAxis valueAxis = new NumberAxis("");
    valueAxis.setAutoRangeIncludesZero(false);
    int timeIndex = -1;
    boolean timeAxisIsDate = false;
    if (forecaster instanceof TSLagUser && data != null) {
        TSLagMaker lagMaker = ((TSLagUser) forecaster).getTSLagMaker();
        if (!lagMaker.isUsingAnArtificialTimeIndex() && lagMaker.getAdjustForTrends()) {
            String timeName = lagMaker.getTimeStampField();
            if (data.attribute(timeName).isDate()) {
                timeAxis = new DateAxis("");
                timeAxisIsDate = true;
                timeIndex = data.attribute(timeName).index();
            }
        }
    }

    if (timeAxis == null) {
        timeAxis = new NumberAxis("");
        ((NumberAxis) timeAxis).setAutoRangeIncludesZero(false);
    }

    // now populate the series
    boolean hasConfidenceIntervals = false;
    for (int i = 0; i < targetNames.size(); i++) {
        String targetName = targetNames.get(i);
        List<NumericPrediction> predsForI = preds.getPredictionsForTarget(targetName);
        int predIndex = xyDataset.indexOf(targetName + "-predicted");
        int actualIndex = xyDataset.indexOf(targetName + "-actual");
        XYIntervalSeries predSeries = xyDataset.getSeries(predIndex);
        XYIntervalSeries actualSeries = xyDataset.getSeries(actualIndex);

        for (int j = 0; j < predsForI.size(); j++) {
            double x = Utils.missingValue();
            if (timeAxisIsDate) {
                if (instanceNumOffset + j + stepNumber - 1 < data.numInstances()) {
                    x = data.instance(instanceNumOffset + j + stepNumber - 1).value(timeIndex);
                }
            } else {
                x = instanceNumOffset + j + stepNumber;
            }

            double yPredicted = predsForI.get(j).predicted();
            double yHigh = yPredicted;
            double yLow = yPredicted;
            double[][] conf = predsForI.get(j).predictionIntervals();
            if (conf.length > 0) {
                yLow = conf[0][0];
                yHigh = conf[0][1];
                hasConfidenceIntervals = true;
            }
            if (!Utils.isMissingValue(x) && !Utils.isMissingValue(yPredicted)) {
                if (predSeries != null) {
                    predSeries.add(x, x, x, yPredicted, yLow, yHigh);
                }
                // System.err.println("* " + yPredicted + " " + x);
            }

            double yActual = predsForI.get(j).actual();
            if (!Utils.isMissingValue(x) && !Utils.isMissingValue(yActual)) {
                if (actualSeries != null) {
                    actualSeries.add(x, x, x, yActual, yActual, yActual);
                }
            }
        }
    }

    // set up the chart
    String title = "" + stepNumber + " step-ahead predictions for: ";
    for (String s : targetNames) {
        title += s + ",";
    }
    title = title.substring(0, title.lastIndexOf(","));

    /*
     * String algoSpec = forecaster.getAlgorithmName(); title += " (" + algoSpec
     * + ")";
     */

    if (forecaster instanceof WekaForecaster && hasConfidenceIntervals) {
        double confPerc = ((WekaForecaster) forecaster).getConfidenceLevel() * 100.0;
        title += " [" + Utils.doubleToString(confPerc, 0) + "% conf. intervals]";
    }

    XYErrorRenderer renderer = new XYErrorRenderer();
    renderer.setBaseLinesVisible(true);
    renderer.setDrawXError(false);
    renderer.setDrawYError(true);
    // renderer.setShapesFilled(true);
    XYPlot plot = new XYPlot(xyDataset, timeAxis, valueAxis, renderer);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    chart.setBackgroundPaint(java.awt.Color.white);
    TextTitle chartTitle = chart.getTitle();
    String fontName = chartTitle.getFont().getFontName();
    java.awt.Font newFont = new java.awt.Font(fontName, java.awt.Font.PLAIN, 12);
    chartTitle.setFont(newFont);

    return chart;
}

From source file:org.esa.snap.rcp.statistics.ScatterPlotPanel.java

private void createUI() {

    final XYPlot plot = getPlot();
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
    plot.setNoDataMessage(NO_DATA_MESSAGE);
    int confidenceDSIndex = 0;
    int regressionDSIndex = 1;
    int scatterpointsDSIndex = 2;
    plot.setDataset(confidenceDSIndex, acceptableDeviationDataset);
    plot.setDataset(regressionDSIndex, regressionDataset);
    plot.setDataset(scatterpointsDSIndex, scatterpointsDataset);

    plot.addAnnotation(r2Annotation);

    final DeviationRenderer identityRenderer = new DeviationRenderer(true, false);
    identityRenderer.setSeriesPaint(0, StatisticChartStyling.SAMPLE_DATA_PAINT);
    identityRenderer.setSeriesFillPaint(0, StatisticChartStyling.SAMPLE_DATA_FILL_PAINT);
    plot.setRenderer(confidenceDSIndex, identityRenderer);

    final DeviationRenderer regressionRenderer = new DeviationRenderer(true, false);
    regressionRenderer.setSeriesPaint(0, StatisticChartStyling.REGRESSION_DATA_PAINT);
    regressionRenderer.setSeriesFillPaint(0, StatisticChartStyling.REGRESSION_DATA_FILL_PAINT);
    plot.setRenderer(regressionDSIndex, regressionRenderer);

    final XYErrorRenderer scatterPointsRenderer = new XYErrorRenderer();
    scatterPointsRenderer.setDrawXError(true);
    scatterPointsRenderer.setErrorStroke(new BasicStroke(1));
    scatterPointsRenderer.setErrorPaint(StatisticChartStyling.CORRELATIVE_POINT_OUTLINE_PAINT);
    scatterPointsRenderer.setSeriesShape(0, StatisticChartStyling.CORRELATIVE_POINT_SHAPE);
    scatterPointsRenderer.setSeriesOutlinePaint(0, StatisticChartStyling.CORRELATIVE_POINT_OUTLINE_PAINT);
    scatterPointsRenderer.setSeriesFillPaint(0, StatisticChartStyling.CORRELATIVE_POINT_FILL_PAINT);
    scatterPointsRenderer.setSeriesLinesVisible(0, false);
    scatterPointsRenderer.setSeriesShapesVisible(0, true);
    scatterPointsRenderer.setSeriesOutlineStroke(0, new BasicStroke(1.0f));
    scatterPointsRenderer.setSeriesToolTipGenerator(0, (dataset, series, item) -> {
        final XYIntervalSeriesCollection collection = (XYIntervalSeriesCollection) dataset;
        final Comparable key = collection.getSeriesKey(series);
        final double xValue = collection.getXValue(series, item);
        final double endYValue = collection.getEndYValue(series, item);
        final double yValue = collection.getYValue(series, item);
        return String.format("%s: mean = %6.2f, sigma = %6.2f | %s: value = %6.2f", getRasterName(), yValue,
                endYValue - yValue, key, xValue);
    });/*w  ww.  j a v  a 2  s .co m*/
    plot.setRenderer(scatterpointsDSIndex, scatterPointsRenderer);

    final boolean autoRangeIncludesZero = false;
    final boolean xLog = scatterPlotModel.xAxisLogScaled;
    final boolean yLog = scatterPlotModel.yAxisLogScaled;
    plot.setDomainAxis(
            StatisticChartStyling.updateScalingOfAxis(xLog, plot.getDomainAxis(), autoRangeIncludesZero));
    plot.setRangeAxis(
            StatisticChartStyling.updateScalingOfAxis(yLog, plot.getRangeAxis(), autoRangeIncludesZero));

    createUI(createChartPanel(chart), createInputParameterPanel(), bindingContext);

    plot.getDomainAxis().addChangeListener(domainAxisChangeListener);
    scatterPlotDisplay.setMouseWheelEnabled(true);
    scatterPlotDisplay.setMouseZoomable(true);
}

From source file:org.esa.beam.visat.toolviews.stat.ScatterPlotPanel.java

private void createUI() {

    final XYPlot plot = getPlot();
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
    plot.setNoDataMessage(NO_DATA_MESSAGE);
    plot.setDataset(CONFIDENCE_DSINDEX, acceptableDeviationDataset);
    plot.setDataset(REGRESSION_DSINDEX, regressionDataset);
    plot.setDataset(SCATTERPOINTS_DSINDEX, scatterpointsDataset);

    plot.addAnnotation(r2Annotation);

    final DeviationRenderer identityRenderer = new DeviationRenderer(true, false);
    identityRenderer.setSeriesPaint(0, StatisticChartStyling.SAMPLE_DATA_PAINT);
    identityRenderer.setSeriesFillPaint(0, StatisticChartStyling.SAMPLE_DATA_FILL_PAINT);
    plot.setRenderer(CONFIDENCE_DSINDEX, identityRenderer);

    final DeviationRenderer regressionRenderer = new DeviationRenderer(true, false);
    regressionRenderer.setSeriesPaint(0, StatisticChartStyling.REGRESSION_DATA_PAINT);
    regressionRenderer.setSeriesFillPaint(0, StatisticChartStyling.REGRESSION_DATA_FILL_PAINT);
    plot.setRenderer(REGRESSION_DSINDEX, regressionRenderer);

    final XYErrorRenderer scatterPointsRenderer = new XYErrorRenderer();
    scatterPointsRenderer.setDrawXError(true);
    scatterPointsRenderer.setErrorStroke(new BasicStroke(1));
    scatterPointsRenderer.setErrorPaint(StatisticChartStyling.CORRELATIVE_POINT_OUTLINE_PAINT);
    scatterPointsRenderer.setSeriesShape(0, StatisticChartStyling.CORRELATIVE_POINT_SHAPE);
    scatterPointsRenderer.setSeriesOutlinePaint(0, StatisticChartStyling.CORRELATIVE_POINT_OUTLINE_PAINT);
    scatterPointsRenderer.setSeriesFillPaint(0, StatisticChartStyling.CORRELATIVE_POINT_FILL_PAINT);
    scatterPointsRenderer.setSeriesLinesVisible(0, false);
    scatterPointsRenderer.setSeriesShapesVisible(0, true);
    scatterPointsRenderer.setSeriesOutlineStroke(0, new BasicStroke(1.0f));
    scatterPointsRenderer.setSeriesToolTipGenerator(0, new XYToolTipGenerator() {
        @Override/*from w  ww. j a va  2s. c o  m*/
        public String generateToolTip(XYDataset dataset, int series, int item) {
            final XYIntervalSeriesCollection collection = (XYIntervalSeriesCollection) dataset;
            final Comparable key = collection.getSeriesKey(series);
            final double xValue = collection.getXValue(series, item);
            final double endYValue = collection.getEndYValue(series, item);
            final double yValue = collection.getYValue(series, item);
            return String.format("%s: mean = %6.2f, sigma = %6.2f | %s: value = %6.2f", getRasterName(), yValue,
                    endYValue - yValue, key, xValue);
        }
    });
    plot.setRenderer(SCATTERPOINTS_DSINDEX, scatterPointsRenderer);

    final boolean autoRangeIncludesZero = false;
    final boolean xLog = scatterPlotModel.xAxisLogScaled;
    final boolean yLog = scatterPlotModel.yAxisLogScaled;
    plot.setDomainAxis(
            StatisticChartStyling.updateScalingOfAxis(xLog, plot.getDomainAxis(), autoRangeIncludesZero));
    plot.setRangeAxis(
            StatisticChartStyling.updateScalingOfAxis(yLog, plot.getRangeAxis(), autoRangeIncludesZero));

    createUI(createChartPanel(chart), createInputParameterPanel(), bindingContext);

    plot.getDomainAxis().addChangeListener(domainAxisChangeListener);
    scatterPlotDisplay.setMouseWheelEnabled(true);
    scatterPlotDisplay.setMouseZoomable(true);
}

From source file:weka.classifiers.timeseries.eval.graph.JFreeChartDriver.java

protected JFreeChart getFutureForecastChart(TSForecaster forecaster, List<List<NumericPrediction>> preds,
        List<String> targetNames, Instances history) {

    if (forecaster instanceof TSLagUser && history != null) {
        TSLagMaker lagMaker = ((TSLagUser) forecaster).getTSLagMaker();
        if (lagMaker.getAdjustForTrends() && !lagMaker.isUsingAnArtificialTimeIndex()) {

            // fill in any missing time stamps only
            history = new Instances(history);
            history = weka.classifiers.timeseries.core.Utils.replaceMissing(history, null,
                    lagMaker.getTimeStampField(), true, lagMaker.getPeriodicity(), lagMaker.getSkipEntries());
        }/*from  www.  j a  v  a2  s  . c  o  m*/
    }

    // set up a collection of series
    XYIntervalSeriesCollection xyDataset = new XYIntervalSeriesCollection();

    if (history != null) {
        // add actual historical data values
        for (String targetName : targetNames) {
            XYIntervalSeries targetSeries = new XYIntervalSeries(targetName, false, false);
            xyDataset.addSeries(targetSeries);
        }
    }

    // add predicted series
    for (String targetName : targetNames) {
        XYIntervalSeries targetSeries = new XYIntervalSeries(targetName + "-predicted", false, false);
        xyDataset.addSeries(targetSeries);
    }

    ValueAxis timeAxis = null;
    NumberAxis valueAxis = new NumberAxis("");
    valueAxis.setAutoRangeIncludesZero(false);
    int timeIndex = -1;
    boolean timeAxisIsDate = false;
    double artificialTimeStart = 0;
    double lastRealTimeValue = Utils.missingValue();
    if (forecaster instanceof TSLagUser && history != null) {
        TSLagMaker lagMaker = ((TSLagUser) forecaster).getTSLagMaker();
        if (!lagMaker.isUsingAnArtificialTimeIndex() && lagMaker.getAdjustForTrends()) {
            String timeName = lagMaker.getTimeStampField();
            if (history.attribute(timeName).isDate()) {
                timeAxis = new DateAxis("");
                timeAxisIsDate = true;
                timeIndex = history.attribute(timeName).index();
            }
        } else {
            try {
                artificialTimeStart = (history != null) ? 1 : lagMaker.getArtificialTimeStartValue() + 1;
            } catch (Exception ex) {
            }
        }
    }

    if (timeAxis == null) {
        timeAxis = new NumberAxis("");
        ((NumberAxis) timeAxis).setAutoRangeIncludesZero(false);
    }

    boolean hasConfidenceIntervals = false;

    // now populate the series
    if (history != null) {

        // do the actuals first
        for (int i = 0; i < history.numInstances(); i++) {
            Instance current = history.instance(i);

            for (String targetName : targetNames) {
                int dataIndex = history.attribute(targetName.trim()).index();

                if (dataIndex >= 0) {
                    XYIntervalSeries actualSeries = null;
                    int actualIndex = xyDataset.indexOf(targetName);
                    actualSeries = xyDataset.getSeries(actualIndex);
                    double x = Utils.missingValue();

                    if (timeAxisIsDate) {
                        x = current.value(timeIndex);
                        if (!Utils.isMissingValue(x)) {
                            lastRealTimeValue = x;
                        }
                    } else {
                        x = artificialTimeStart;
                    }

                    double y = Utils.missingValue();
                    y = current.value(dataIndex);

                    if (!Utils.isMissingValue(x) && !Utils.isMissingValue(y)) {
                        if (actualSeries != null) {
                            actualSeries.add(x, x, x, y, y, y);
                        }
                    }
                }
            }

            if (!timeAxisIsDate) {
                artificialTimeStart++;
            }
        }
    }

    // now do the futures
    List<String> forecasterTargets = AbstractForecaster.stringToList(forecaster.getFieldsToForecast());

    // loop over the steps
    for (int j = 0; j < preds.size(); j++) {
        List<NumericPrediction> predsForStepJ = preds.get(j);

        // advance the real time index (if appropriate)
        if (timeAxisIsDate) {
            lastRealTimeValue = ((TSLagUser) forecaster).getTSLagMaker()
                    .advanceSuppliedTimeValue(lastRealTimeValue);
        }
        for (String targetName : targetNames) {

            // look up this requested target in the list that the forecaster
            // has predicted
            int predIndex = forecasterTargets.indexOf(targetName.trim());
            if (predIndex >= 0) {
                NumericPrediction predsForTargetAtStepJ = predsForStepJ.get(predIndex);
                XYIntervalSeries predSeries = null;
                int datasetIndex = xyDataset.indexOf(targetName + "-predicted");
                predSeries = xyDataset.getSeries(datasetIndex);

                if (predSeries != null) {
                    double y = predsForTargetAtStepJ.predicted();
                    double x = Utils.missingValue();
                    double yHigh = y;
                    double yLow = y;
                    double[][] conf = predsForTargetAtStepJ.predictionIntervals();
                    if (conf.length > 0) {
                        yLow = conf[0][0];
                        yHigh = conf[0][1];
                        hasConfidenceIntervals = true;
                    }

                    if (!timeAxisIsDate) {
                        x = artificialTimeStart;
                    } else {
                        x = lastRealTimeValue;
                    }

                    if (!Utils.isMissingValue(x) && !Utils.isMissingValue(y)) {
                        predSeries.add(x, x, x, y, yLow, yHigh);
                    }
                }
            }
        }

        // advance the artificial time index (if appropriate)
        if (!timeAxisIsDate) {
            artificialTimeStart++;
        }
    }

    String title = "Future forecast for: ";
    for (String s : targetNames) {
        title += s + ",";
    }
    title = title.substring(0, title.lastIndexOf(","));

    /*
     * String algoSpec = forecaster.getAlgorithmName(); title += " (" + algoSpec
     * + ")";
     */

    if (forecaster instanceof WekaForecaster && hasConfidenceIntervals) {
        double confPerc = ((WekaForecaster) forecaster).getConfidenceLevel() * 100.0;
        title += " [" + Utils.doubleToString(confPerc, 0) + "% conf. intervals]";
    }

    XYErrorRenderer renderer = new XYErrorRenderer();

    // renderer.setShapesFilled(true);
    XYPlot plot = new XYPlot(xyDataset, timeAxis, valueAxis, renderer);
    // renderer = (XYErrorRenderer)plot.getRenderer();
    if (history != null) {
        for (String targetName : targetNames) {
            XYIntervalSeries predSeries = null;
            int predIndex = xyDataset.indexOf(targetName + "-predicted");
            predSeries = xyDataset.getSeries(predIndex);

            XYIntervalSeries actualSeries = null;
            int actualIndex = xyDataset.indexOf(targetName);
            actualSeries = xyDataset.getSeries(actualIndex);

            if (actualSeries != null && predSeries != null) {
                // match the color of the actual series
                java.awt.Paint actualPaint = renderer.lookupSeriesPaint(actualIndex);
                renderer.setSeriesPaint(predIndex, actualPaint);

                // now set the line style to dashed
                BasicStroke dashed = new BasicStroke(1.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f,
                        new float[] { 5.0f }, 0.0f);

                renderer.setSeriesStroke(predIndex, dashed);
            }
        }
    }

    renderer.setBaseLinesVisible(true);
    renderer.setDrawXError(false);
    renderer.setDrawYError(true);

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    chart.setBackgroundPaint(java.awt.Color.white);
    TextTitle chartTitle = chart.getTitle();
    String fontName = chartTitle.getFont().getFontName();
    java.awt.Font newFont = new java.awt.Font(fontName, java.awt.Font.PLAIN, 12);
    chartTitle.setFont(newFont);

    return chart;
}