Example usage for org.jfree.chart.plot XYPlot addAnnotation

List of usage examples for org.jfree.chart.plot XYPlot addAnnotation

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot addAnnotation.

Prototype

public void addAnnotation(XYAnnotation annotation) 

Source Link

Document

Adds an annotation to the plot and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:no.met.jtimeseries.chart.ErrorPlot.java

public static XYPlot getMarinogramErrorPlot() {
    XYItemRenderer renderer = new StandardXYItemRenderer();
    NumberAxis rangeAxis = new NumberAxis();
    XYPlot plot = new XYPlot(null, null, rangeAxis, renderer);
    XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 0.5, 0.5);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    plot.addAnnotation(annotation);
    return plot;//from w  w w.j a v  a  2 s  .  c om
}

From source file:y.graphs.ChartHelperELF.java

private static JFreeChart createChart(final TimeSeriesCollection dataset, Date from, Date to, Config config,
        ArrayList<ConfigSerie> series) {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart(Config.getResource("MsgTitleMagGraph"),
            Config.getResource("TitleDate"), Config.getResource("MsgTitleMagGraphYAxis"), dataset, true, // include legend
            true, // tooltips
            false // urls
    );//  w ww .  j  av a 2s.c o m

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    LegendTitle lt = new LegendTitle(plot);
    lt.setItemFont(new Font("Dialog", Font.PLAIN, 12));
    lt.setBackgroundPaint(Color.white);
    lt.setFrame(new BlockBorder(Color.white));
    lt.setVerticalAlignment(VerticalAlignment.CENTER);
    XYTitleAnnotation ta = new XYTitleAnnotation(config.getLegendX(), config.getLegendY(), lt,
            RectangleAnchor.TOP_RIGHT);
    ta.setMaxWidth(config.getLegendSize());
    plot.addAnnotation(ta);
    chart.removeLegend();

    plot.setBackgroundPaint(config.getColorBackgroundELF());
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    final Stroke lineStroke = new BasicStroke((float) config.getLineWidthELF());

    for (int si = 0; si < series.size(); si++) {
        final ConfigSerie cs = series.get(si);
        renderer.setSeriesLinesVisible(si, cs.isDrawLine());

        final float size = cs.getShapeSize();
        renderer.setSeriesShapesVisible(si, size > 0);
        if (size > 0)
            renderer.setSeriesShape(si, ShapeUtilities.createRegularCross(size, size));

        renderer.setSeriesStroke(si, lineStroke);
        //            renderer.setSeriesOutlineStroke(si, lineStroke);
        renderer.setSeriesPaint(si, cs.getColor());
    }
    plot.setRenderer(renderer);

    // x axis
    final DateAxis rangeAxis = (DateAxis) plot.getDomainAxis();
    //        rangeAxis.setStandardTickUnits(DateAxis.createStandardDateTickUnits()); // Returns a collection of standard date tick units that uses the default time zone. This collection will be used by default, but you are free to create your own collection if you want to
    rangeAxis.setAutoRange(true);
    //        rangeAxis.setRange(from, to);
    rangeAxis.setLowerMargin(0.01);
    rangeAxis.setUpperMargin(0.01);

    {
        final Font axisFont = config.getAxisFont();
        if (axisFont != null) {
            rangeAxis.setLabelFont(axisFont);
            plot.getRangeAxis().setLabelFont(axisFont);
        }
    }

    final String xaxisFmt = config.getAxisFormat();

    if (xaxisFmt == null || xaxisFmt.isEmpty()) {
        double diffInDays = (to.getTime() - from.getTime()) / (1000.0 * 60.0 * 60.0 * 24.0);
        if (diffInDays < 2)
            rangeAxis.setDateFormatOverride(
                    new SimpleDateFormat(Config.DEFAULT_TIMEFMT, DateFormatSymbols.getInstance()));
        else
            rangeAxis.setDateFormatOverride(
                    new SimpleDateFormat(Config.DEFAULT_SHORTTIMEFMT, DateFormatSymbols.getInstance()));
    } else
        rangeAxis.setDateFormatOverride(new SimpleDateFormat(xaxisFmt, DateFormatSymbols.getInstance()));

    final ValueAxis domain = plot.getRangeAxis();
    if (config.getForceYmin() != 0 || config.getForceYmax() != 0)
        domain.setRange(ElfValue.valueIntToDouble(config.getForceYmin()),
                ElfValue.valueIntToDouble(config.getForceYmax()));

    // title
    final Font titleFont = config.getTitleFont();
    if (titleFont != null)
        chart.getTitle().setFont(titleFont);

    return chart;
}

From source file:y.graphs.ChartHelperSRB.java

private static JFreeChart createChart(final TimeSeriesCollection dataset, Date from, Date to, Config config,
        ArrayList<ConfigSerie> series) {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart(Config.getResource("MsgTitleSrbGraph"),
            Config.getResource("TitleDate"), Config.getResource("MsgTitleSrbGraphYAxis"), dataset, true, // include legend
            true, // tooltips
            false // urls
    );/*from   ww w  .  ja  va2  s.co m*/

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    LegendTitle lt = new LegendTitle(plot);
    lt.setItemFont(new Font("Dialog", Font.PLAIN, 12));
    lt.setBackgroundPaint(Color.white);
    lt.setFrame(new BlockBorder(Color.white));
    lt.setVerticalAlignment(VerticalAlignment.CENTER);
    XYTitleAnnotation ta = new XYTitleAnnotation(config.getLegendX(), config.getLegendY(), lt,
            RectangleAnchor.TOP_RIGHT);
    ta.setMaxWidth(config.getLegendSize());
    plot.addAnnotation(ta);
    chart.removeLegend();

    plot.setBackgroundPaint(config.getColorBackgroundSRB());
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    final Stroke lineStroke = new BasicStroke((float) config.getLineWidthSRB());

    for (int si = 0; si < series.size(); si++) {
        final ConfigSerie cs = series.get(si);
        renderer.setSeriesLinesVisible(si, cs.isDrawLine());

        final float size = cs.getShapeSize();
        renderer.setSeriesShapesVisible(si, size > 0);
        if (size > 0)
            renderer.setSeriesShape(si, ShapeUtilities.createRegularCross(size, size));

        renderer.setSeriesStroke(si, lineStroke);
        //          renderer.setSeriesOutlineStroke(si, lineStroke);
        renderer.setSeriesPaint(si, cs.getColor());
    }
    plot.setRenderer(renderer);

    // x axis
    final DateAxis rangeAxis = (DateAxis) plot.getDomainAxis();
    //      rangeAxis.setStandardTickUnits(DateAxis.createStandardDateTickUnits()); // Returns a collection of standard date tick units that uses the default time zone. This collection will be used by default, but you are free to create your own collection if you want to
    rangeAxis.setAutoRange(true);
    //        rangeAxis.setRange(from, to);
    rangeAxis.setLowerMargin(0.01);
    rangeAxis.setUpperMargin(0.01);

    {
        final Font axisFont = config.getAxisFont();
        if (axisFont != null) {
            rangeAxis.setLabelFont(axisFont);
            plot.getRangeAxis().setLabelFont(axisFont);
        }
    }

    final String xaxisFmt = config.getAxisFormat();

    if (xaxisFmt == null || xaxisFmt.isEmpty()) {
        double diffInDays = (to.getTime() - from.getTime()) / (1000.0 * 60.0 * 60.0 * 24.0);
        if (diffInDays < 2)
            rangeAxis.setDateFormatOverride(
                    new SimpleDateFormat(Config.DEFAULT_TIMEFMT, DateFormatSymbols.getInstance()));
        else
            rangeAxis.setDateFormatOverride(
                    new SimpleDateFormat(Config.DEFAULT_SHORTTIMEFMT, DateFormatSymbols.getInstance()));
    } else
        rangeAxis.setDateFormatOverride(new SimpleDateFormat(xaxisFmt, DateFormatSymbols.getInstance()));

    final ValueAxis domain = plot.getRangeAxis();
    if (config.getForceYmin() != 0 || config.getForceYmax() != 0)
        domain.setRange(ElfValue.valueIntToDouble(config.getForceYmin()),
                ElfValue.valueIntToDouble(config.getForceYmax()));

    // title
    final Font titleFont = config.getTitleFont();
    if (titleFont != null)
        chart.getTitle().setFont(titleFont);

    return chart;
}

From source file:de.bfs.radon.omsimulation.gui.data.OMCharts.java

/**
 * Creates a chart displaying the distribution of certain selected statistical
 * values. Uses red for normal rooms and blue for cellar rooms.
 * //from  www.j  a  va 2 s. co  m
 * @param title
 *          The headline of the chart. Will be hidden if set to null.
 * @param statistics
 *          The selected statistics of a campaign containing all needed
 *          values.
 * @param roomType
 *          The room type to determine the colour of the chart.
 * @param preview
 *          Will hide annotations, labels and headlines if true.
 * @return A chart displaying the distribution of certain selected statistical
 *         values.
 */
public static JFreeChart createDistributionChart(String title, DescriptiveStatistics statistics,
        OMRoomType roomType, boolean preview) {
    Color lineColor = new Color(0, 0, 0, 128);
    Color rangeColor = new Color(222, 222, 222, 128);
    if (roomType == OMRoomType.Room) {
        lineColor = new Color(255, 0, 0, 128);
        rangeColor = new Color(255, 222, 222, 128);
    } else {
        if (roomType == OMRoomType.Cellar) {
            lineColor = new Color(0, 0, 255, 128);
            rangeColor = new Color(222, 222, 255, 128);
        } else {
            lineColor = new Color(0, 128, 0, 255);
            rangeColor = new Color(222, 255, 222, 128);
        }
    }
    double[] distValues = statistics.getSortedValues();
    XYSeriesCollection dataSet = new XYSeriesCollection();
    XYSeries distSeries = new XYSeries("Distribution");
    for (int i = 0; i < distValues.length; i++) {
        distSeries.add(distValues[i], (0.5 + (double) i) / (double) distValues.length);
    }
    dataSet.addSeries(distSeries);
    JFreeChart chart = ChartFactory.createXYLineChart(title, "Rn [Bq/m\u00B3]", "F(emp)", dataSet,
            PlotOrientation.VERTICAL, false, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    float[] dash = { 5, 3 };
    int pos = 0;
    double y = (Double) distSeries.getY(pos);
    XYPointerAnnotation minPointer = new XYPointerAnnotation("MIN=" + (int) distValues[pos], distValues[pos], y,
            Math.PI * 1.5);
    plot.addAnnotation(minPointer);
    pos = (int) (((double) distValues.length / 100. * 5.0) - 1.0);
    while (pos < 0) {
        pos++;
    }
    if (pos > 0) {
        y = (Double) distSeries.getY(pos);
    } else {
        y = (Double) distSeries.getY(pos + 1);
    }
    final double posQ5 = distValues[pos];
    XYPointerAnnotation q05Pointer = new XYPointerAnnotation("Q5=" + (int) distValues[pos], distValues[pos], y,
            Math.PI * 1.5);
    plot.addAnnotation(q05Pointer);
    pos = (int) (((double) distValues.length / 2.0) - 1.0);
    y = (Double) distSeries.getY(pos);
    XYPointerAnnotation q50Pointer = new XYPointerAnnotation("Q50=" + (int) distValues[pos], distValues[pos], y,
            Math.PI * 1.5);
    plot.addAnnotation(q50Pointer);
    ValueMarker medMarker = new ValueMarker(distValues[pos], lineColor,
            new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0));
    plot.addDomainMarker(medMarker);
    pos = (int) (((double) distValues.length / 100.0 * 95.0) - 1.0);
    if (pos < distValues.length - 1) {
        y = (Double) distSeries.getY(pos);
    } else {
        y = (Double) distSeries.getY(pos - 1);
    }
    final double posQ95 = distValues[pos];
    XYPointerAnnotation q95Pointer = new XYPointerAnnotation("Q95=" + (int) distValues[pos], distValues[pos], y,
            Math.PI * 0.5);
    plot.addAnnotation(q95Pointer);
    pos = distValues.length - 1;
    y = (Double) distSeries.getY(pos);
    XYPointerAnnotation maxPointer = new XYPointerAnnotation("MAX=" + (int) distValues[pos], distValues[pos], y,
            Math.PI * 0.5);
    plot.addAnnotation(maxPointer);
    IntervalMarker percentiles = new IntervalMarker(posQ5, posQ95);
    percentiles.setPaint(rangeColor);
    percentiles.setStroke(new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0));
    plot.addDomainMarker(percentiles, Layer.BACKGROUND);
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, lineColor);
    return chart;
}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createXYLineChart(null, "Age in Months", "Weight (kg)", xydataset,
            PlotOrientation.VERTICAL, true, true, false);
    TextTitle texttitle = new TextTitle("Growth Charts: United States", new Font("SansSerif", 1, 14));
    TextTitle texttitle1 = new TextTitle("Weight-for-age percentiles: boys, birth to 36 months",
            new Font("SansSerif", 0, 11));
    jfreechart.addSubtitle(texttitle);//from www. j  a v  a2s  . c  om
    jfreechart.addSubtitle(texttitle1);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    NumberAxis numberaxis = (NumberAxis) xyplot.getDomainAxis();
    numberaxis.setUpperMargin(0.12D);
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    NumberAxis numberaxis1 = (NumberAxis) xyplot.getRangeAxis();
    numberaxis1.setAutoRangeIncludesZero(false);
    XYTextAnnotation xytextannotation = null;
    Font font = new Font("SansSerif", 0, 9);
    xytextannotation = new XYTextAnnotation("3rd", 36.5D, 11.76D);
    xytextannotation.setFont(font);
    xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT);
    xyplot.addAnnotation(xytextannotation);
    xytextannotation = new XYTextAnnotation("5th", 36.5D, 12.039999999999999D);
    xytextannotation.setFont(font);
    xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT);
    xyplot.addAnnotation(xytextannotation);
    xytextannotation = new XYTextAnnotation("10th", 36.5D, 12.493D);
    xytextannotation.setFont(font);
    xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT);
    xyplot.addAnnotation(xytextannotation);
    xytextannotation = new XYTextAnnotation("25th", 36.5D, 13.313000000000001D);
    xytextannotation.setFont(font);
    xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT);
    xyplot.addAnnotation(xytextannotation);
    xytextannotation = new XYTextAnnotation("50th", 36.5D, 14.33D);
    xytextannotation.setFont(font);
    xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT);
    xyplot.addAnnotation(xytextannotation);
    xytextannotation = new XYTextAnnotation("75th", 36.5D, 15.478D);
    xytextannotation.setFont(font);
    xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT);
    xyplot.addAnnotation(xytextannotation);
    xytextannotation = new XYTextAnnotation("90th", 36.5D, 16.641999999999999D);
    xytextannotation.setFont(font);
    xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT);
    xyplot.addAnnotation(xytextannotation);
    xytextannotation = new XYTextAnnotation("95th", 36.5D, 17.408000000000001D);
    xytextannotation.setFont(font);
    xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT);
    xyplot.addAnnotation(xytextannotation);
    xytextannotation = new XYTextAnnotation("97th", 36.5D, 17.936D);
    xytextannotation.setFont(font);
    xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT);
    xyplot.addAnnotation(xytextannotation);
    return jfreechart;
}

From source file:org.jfree.experimental.chart.demo.XYTitleAnnotationDemo1.java

/**
 * Creates a chart./*from  ww  w .  j  av  a 2s  . c  om*/
 * 
 * @param dataset  a dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", // title
            "Date", // x-axis label
            "Price Per Unit", // y-axis label
            dataset, // data
            false, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    LegendTitle lt = new LegendTitle(plot);
    lt.setItemFont(new Font("Dialog", Font.PLAIN, 9));
    lt.setBackgroundPaint(new Color(200, 200, 255, 100));
    lt.setFrame(new BlockBorder(Color.white));
    lt.setPosition(RectangleEdge.BOTTOM);
    XYTitleAnnotation ta = new XYTitleAnnotation(0.98, 0.02, lt, RectangleAnchor.BOTTOM_RIGHT);

    ta.setMaxWidth(0.48);
    plot.addAnnotation(ta);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
    }

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));

    ValueAxis yAxis = plot.getRangeAxis();
    yAxis.setLowerMargin(0.35);
    return chart;

}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", "Date",
            "Price Per Unit", xydataset, false, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);
    LegendTitle legendtitle = new LegendTitle(xyplot);
    legendtitle.setItemFont(new Font("Dialog", 0, 9));
    legendtitle.setBackgroundPaint(new Color(200, 200, 255, 100));
    legendtitle.setFrame(new BlockBorder(Color.white));
    legendtitle.setPosition(RectangleEdge.BOTTOM);
    XYTitleAnnotation xytitleannotation = new XYTitleAnnotation(0.97999999999999998D, 0.02D, legendtitle,
            RectangleAnchor.BOTTOM_RIGHT);
    xytitleannotation.setMaxWidth(0.47999999999999998D);
    xyplot.addAnnotation(xytitleannotation);
    org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer();
    if (xyitemrenderer instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer;
        xylineandshaperenderer.setBaseShapesVisible(true);
        xylineandshaperenderer.setBaseShapesFilled(true);
    }/*from w  ww .  j  a v a  2 s.  c o  m*/
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    ValueAxis valueaxis = xyplot.getRangeAxis();
    valueaxis.setLowerMargin(0.34999999999999998D);
    return jfreechart;
}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createXYAreaChart("XY Area Chart Demo", "Domain (X)", "Range (Y)",
            xydataset, PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setForegroundAlpha(0.65F);//from  ww  w  .j  a  v a  2 s  .  c  om
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    ValueAxis valueaxis = xyplot.getDomainAxis();
    valueaxis.setTickMarkPaint(Color.black);
    valueaxis.setLowerMargin(0.0D);
    valueaxis.setUpperMargin(0.0D);
    ValueAxis valueaxis1 = xyplot.getRangeAxis();
    valueaxis1.setTickMarkPaint(Color.black);
    XYPointerAnnotation xypointerannotation = new XYPointerAnnotation("Test", 5D, -500D, 2.3561944901923448D);
    xypointerannotation.setTipRadius(0.0D);
    xypointerannotation.setBaseRadius(35D);
    xypointerannotation.setFont(new Font("SansSerif", 0, 9));
    xypointerannotation.setPaint(Color.blue);
    xypointerannotation.setTextAnchor(TextAnchor.HALF_ASCENT_RIGHT);
    xyplot.addAnnotation(xypointerannotation);
    return jfreechart;
}

From source file:de.berlios.statcvs.xml.chart.AbstractTimeSeriesChart.java

protected void addSymbolicNames(Iterator it) {
    XYPlot xyplot = getChart().getXYPlot();
    while (it.hasNext()) {
        SymbolicName sn = (SymbolicName) it.next();
        if (sn.getDate() != null) {
            xyplot.addAnnotation(new SymbolicNameAnnotation(sn));
        }/*from  w  w  w  .  j  a  va  2  s  .co  m*/
    }
}

From source file:utils.ChartUtils.java

/**
 * Update XY chart//from  ww w. j ava 2 s . co m
 * 
 * @param plot ChartPanel Plot
 * @param sortedArray Sorted array of values
 */
public static void updateXYChart(ChartPanel plot, double[] sortedArray) {

    XYPlot xyplot = plot.getChart().getXYPlot();

    double min = sortedArray[0];
    double max = sortedArray[sortedArray.length - 1];

    double median = Utils.getMedian(sortedArray);

    double q1 = Utils.getQ1(sortedArray);
    double q3 = Utils.getQ3(sortedArray);

    XYTextAnnotation annotation;

    //min-lowlimit horizontal
    XYSeries serie15 = new XYSeries("15");
    serie15.add(min, 0.5);

    //max-toplimit horizontal
    XYSeries serie16 = new XYSeries("16");
    serie16.add(max, 0.5);

    //min vertical
    XYSeries serie1 = new XYSeries("0");
    serie1.add(min, 0.45);
    serie1.add(min, 0.55);

    annotation = new XYTextAnnotation("Min", min, 0.40);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 11));
    xyplot.addAnnotation(annotation);

    //min-q1 horizontal
    XYSeries serie2 = new XYSeries("1");
    serie2.add(min, 0.5);
    serie2.add(q1, 0.5);

    //q1 vertical  
    XYSeries serie3 = new XYSeries("2");
    serie3.add(q1, 0.1);
    serie3.add(q1, 0.9);

    annotation = new XYTextAnnotation("Q1", q1, 0.08);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 11));
    xyplot.addAnnotation(annotation);

    // median 
    XYSeries serie_mediana = new XYSeries("11");
    serie_mediana.add(median, 0.1);
    serie_mediana.add(median, 0.9);

    annotation = new XYTextAnnotation("Median", median, 0.04);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 11));
    xyplot.addAnnotation(annotation);

    //q1-q3 horizontal sup
    XYSeries serie4 = new XYSeries("3");
    serie4.add(q1, 0.9);
    serie4.add(q3, 0.9);

    //q1-q3 horizontal inf
    XYSeries serie5 = new XYSeries("4");
    serie5.add(q1, 0.1);
    serie5.add(q3, 0.1);

    //q3 vertical
    XYSeries serie6 = new XYSeries("5");
    serie6.add(q3, 0.1);
    serie6.add(q3, 0.9);

    annotation = new XYTextAnnotation("Q3", q3, 0.08);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 11));
    xyplot.addAnnotation(annotation);

    //q3-max horizontal
    XYSeries serie7 = new XYSeries("6");
    serie7.add(q3, 0.5);
    serie7.add(max, 0.5);

    //max vertical
    XYSeries serie8 = new XYSeries("7");
    serie8.add(max, 0.45);
    serie8.add(max, 0.55);

    annotation = new XYTextAnnotation("Max", max, 0.4);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 11));
    xyplot.addAnnotation(annotation);

    XYSeriesCollection xyseriescollection = new XYSeriesCollection();

    xyseriescollection.addSeries(serie1);
    xyseriescollection.addSeries(serie2);
    xyseriescollection.addSeries(serie3);
    xyseriescollection.addSeries(serie4);
    xyseriescollection.addSeries(serie5);
    xyseriescollection.addSeries(serie6);
    xyseriescollection.addSeries(serie7);
    xyseriescollection.addSeries(serie8);
    xyseriescollection.addSeries(serie15);
    xyseriescollection.addSeries(serie16);
    xyseriescollection.addSeries(serie_mediana);

    xyplot.getRenderer().setSeriesPaint(9, Color.black);
    xyplot.getRenderer().setSeriesPaint(10, Color.black);

    xyplot.getRenderer().setSeriesPaint(0, Color.black);
    xyplot.getRenderer().setSeriesPaint(1, Color.black);
    xyplot.getRenderer().setSeriesPaint(2, Color.black);
    xyplot.getRenderer().setSeriesPaint(3, Color.black);
    xyplot.getRenderer().setSeriesPaint(4, Color.black);
    xyplot.getRenderer().setSeriesPaint(5, Color.black);
    xyplot.getRenderer().setSeriesPaint(6, Color.black);
    xyplot.getRenderer().setSeriesPaint(7, Color.black);
    xyplot.getRenderer().setSeriesPaint(8, Color.black);
    xyplot.getRenderer().setSeriesPaint(9, Color.black);
    xyplot.getRenderer().setSeriesPaint(10, Color.black);
    xyplot.getRenderer().setSeriesPaint(11, Color.black);
    xyplot.getRenderer().setSeriesPaint(12, Color.black);
    xyplot.getRenderer().setSeriesPaint(13, Color.black);

    //add dataset
    xyplot.setDataset(xyseriescollection);

    // add a second dataset and renderer... 
    XYSeriesCollection anotherserie = new XYSeriesCollection();

    XYSeries serie_point = new XYSeries("21");

    double[] yValue = { 0.47, 0.49, 0.51, 0.53 };

    for (int i = 0, j = 0; i < sortedArray.length; i++, j++) {
        if (j % 4 == 0) {
            j = 0;
        }
        serie_point.add(sortedArray[i], yValue[j]);
    }

    anotherserie.addSeries(serie_point);

    XYLineAndShapeRenderer renderer1 = new XYLineAndShapeRenderer(false, true);
    renderer1.setSeriesPaint(0, Color.lightGray);

    xyplot.setDataset(1, anotherserie);
    xyplot.setRenderer(1, renderer1);
}