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

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

Introduction

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

Prototype

public void setRangeGridlinePaint(Paint paint) 

Source Link

Document

Sets the paint for the grid lines plotted against the range axis and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:CargarEntrenamiento.grafica2.java

public void iejmplo() {

    s1.add(new Month(2, 2001), 181.8);
    //s1.add(new Week(1, 1), null);
    s1.add(new Month(3, 2001), 167.3);
    s1.add(new Month(4, 2001), 153.8);
    s1.add(new Month(5, 2001), 167.6);
    s1.add(new Month(6, 2001), 158.8);
    s1.add(new Month(7, 2001), 148.3);
    s1.add(new Month(8, 2001), 153.9);
    s1.add(new Month(9, 2001), 142.7);
    s1.add(new Month(10, 2001), 123.2);
    s1.add(new Month(11, 2001), 131.8);
    s1.add(new Month(12, 2001), 139.6);
    s1.add(new Month(1, 2002), 142.9);
    s1.add(new Month(2, 2002), 138.7);
    s1.add(new Month(3, 2002), 137.3);
    s1.add(new Month(4, 2002), 143.9);
    s1.add(new Month(5, 2002), 139.8);
    s1.add(new Month(6, 2002), 137.0);
    s1.add(new Month(7, 2002), 132.8);

    TimeSeries s2 = new TimeSeries("L&G UK Index Trust");
    s2.add(new Month(2, 2001), 129.6);
    s2.add(new Month(3, 2001), 123.2);
    s2.add(new Month(4, 2001), 117.2);
    s2.add(new Month(5, 2001), 124.1);
    s2.add(new Month(6, 2001), 122.6);
    s2.add(new Month(7, 2001), 119.2);
    s2.add(new Month(8, 2001), 116.5);
    s2.add(new Month(9, 2001), 112.7);
    s2.add(new Month(10, 2001), 101.5);
    s2.add(new Month(11, 2001), 106.1);
    s2.add(new Month(12, 2001), 110.3);
    s2.add(new Month(1, 2002), 111.7);
    s2.add(new Month(2, 2002), 111.0);
    s2.add(new Month(3, 2002), 109.6);
    s2.add(new Month(4, 2002), 113.2);
    s2.add(new Month(5, 2002), 111.6);
    s2.add(new Month(6, 2002), 108.8);
    s2.add(new Month(7, 2002), 101.6);

    TimeSeries s3 = new TimeSeries("andres2255");
    s3.add(new Month(2, 2001), 129.6);

    s3.add(new Month(10, 2001), 106.1);
    s3.add(new Month(1, 2002), 111.7);
    s3.add(new Month(2, 2002), 111.0);
    datos.addSeries(s1);//from   ww w . j  ava  2 s . c  o  m
    datos.addSeries(s2);
    datos.addSeries(s3);

    grafica = ChartFactory.createTimeSeriesChart("titulo", "etiquetas X", "etiquetaY", datos, true, true,
            false);
    /// 
    grafica.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) grafica.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);

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

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

From source file:ec.nbdemetra.sa.revisionanalysis.RevisionAnalysisChart.java

@Override
protected void onColorSchemeChange() {
    XYPlot plot = chartPanel.getChart().getXYPlot();
    for (int i = 0; i < plot.getDataset().getSeriesCount(); i++) {
        plot.getRenderer().setSeriesPaint(i, themeSupport.getLineColor(i));
    }/* w  w w . j a v a  2 s.  c  o m*/
    plot.setBackgroundPaint(themeSupport.getPlotColor());
    plot.setDomainGridlinePaint(themeSupport.getGridColor());
    plot.setRangeGridlinePaint(themeSupport.getGridColor());
    chartPanel.getChart().setBackgroundPaint(themeSupport.getBackColor());
}

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

private JFreeChart createChart(XYDataset xydataset, String title, String xtitle, String ytitle) {
    JFreeChart chart = ChartFactory.createXYLineChart(title, xtitle, ytitle, 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:edu.unibonn.plotting.TimeSeriesPlotter_Sensors.java

private JFreeChart createChart(final XYDataset dataset, final XYDataset dataset_centroids,
        ArrayList<Cluster_KMeans> clusters) {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart("Sensors", "Time", "Erlang", dataset, false, //t
            true, //t
            false //f
    );/*ww  w  .  j av a 2s  .  co  m*/

    ChartUtilities.applyCurrentTheme(chart);

    //chart.setBackgroundPaint(Color.white);

    //        final StandardLegend sl = (StandardLegend) chart.getLegend();
    //        sl.setDisplaySeriesShapes(true);

    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    //        plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    final XYItemRenderer renderer = plot.getRenderer();

    if (renderer instanceof StandardXYItemRenderer) {
        final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer;
        //rr.setPlotShapes(true);
        rr.setShapesFilled(true);
        rr.setItemLabelsVisible(true);
    }

    int temp_count = 0;

    //for (int i = 0; i < clusters.size(); i++)
    for (int i = 0; (i < 11) && (i < clusters.size()); i++) {
        Cluster_KMeans current_cluster = clusters.get(i);
        ArrayList<Sensor> member_time_series = current_cluster.getMembership();

        for (int j = 0; j < member_time_series.size(); j++) {
            renderer.setSeriesPaint(j + temp_count, getColor(i));
        }
        temp_count = temp_count + member_time_series.size();
    }

    final DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("HH:mm"));

    //final ValueAxis axis_y = plot.getRangeAxis();
    //axis_y.setRange(0, 20);

    plot.setDataset(1, dataset_centroids);
    plot.setRenderer(1, new StandardXYItemRenderer());

    for (int i = 0; (i < clusters.size()); i++) {
        //plot.getRenderer(1).setSeriesPaint(i, getColor(i));
        plot.getRenderer(1).setSeriesPaint(i, Color.BLACK);
        plot.getRenderer(1).setSeriesStroke(i, new BasicStroke(3.0f, BasicStroke.CAP_ROUND,
                BasicStroke.JOIN_ROUND, 1.0f, new float[] { 10.0f, 6.0f }, 0.0f));
    }

    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    return chart;
}

From source file:edu.ucla.stat.SOCR.chart.demo.MultiIndexChart.java

/**
 * Creates a chart./*from  ww w .  ja  v a  2  s .c om*/
 * 
 * @param dataset  the data for the chart.
 * 
 * @return a chart.
 */
protected JFreeChart createChart(XYDataset dataset) {

    //   create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title
            domainLabel, // x axis label 
            rangeLabel, // y axis label  
            dataset, // data
            PlotOrientation.VERTICAL, !legendPanelOn, // include legend
            true, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    XYPlot plot = (XYPlot) chart.getPlot();

    plot.setBackgroundPaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    //  renderer.setSeriesShape(0, java.awt.Shape.round);
    renderer.setBaseShapesVisible(false);
    renderer.setBaseShapesFilled(false);
    renderer.setBaseLinesVisible(true);

    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

    //change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setUpperMargin(0.05);
    rangeAxis.setLowerMargin(0.05);

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    domainAxis.setAutoRangeIncludesZero(false);
    //  domainAxis.setTickLabelsVisible(false);
    //  domainAxis.setTickMarksVisible(false);      
    domainAxis.setUpperMargin(0.05);
    domainAxis.setLowerMargin(0.05);

    // OPTIONAL CUSTOMISATION COMPLETED.
    setYSummary(dataset);

    return chart;
}

From source file:org.n52.io.type.quantity.handler.img.ChartIoHandler.java

private XYPlot createPlotArea(JFreeChart chart) {
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0));
    showCrosshairsOnAxes(plot);/*from w ww .  j a v  a 2 s.c om*/
    configureDomainAxis(plot);
    showGridlinesOnChart(plot);
    configureTimeAxis(plot);
    configureTitle(chart);
    addNotice(chart);
    return plot;
}

From source file:com.bt.aloha.sipstone.GenGraph.java

private JFreeChart createSingleChart() {
    XYDataset xydatasetArray[] = createDataset_CallsPerSecond_AvgResponseTime();
    XYDataset xydataset = xydatasetArray[0];
    final XYDataset percXydataset = xydatasetArray[1];
    JFreeChart jfreechart = ChartFactory.createXYLineChart("SIPStone result", "Calls per second",
            "Avg response time", xydataset, PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    XYItemRenderer xyrenderer = (XYItemRenderer) xyplot.getRenderer();
    xyrenderer.setBaseItemLabelGenerator(new MyXYItemLabelGenerator(percXydataset));
    xyrenderer.setBaseItemLabelsVisible(true);
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setAutoRangeIncludesZero(false);
    numberaxis.setAutoRange(true);//from ww w.  ja  v  a 2s  .  c  om
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    return jfreechart;
}

From source file:Perfil_Deportivo.graficaEntrenamientoCargado.java

public graficaEntrenamientoCargado() {
    datos.removeAllSeries();//from   w  w  w  . java2  s  . c  o m
    //sxy.add(x[0], y[0]);
    pesos = new double[EntrenamientoCargado.pesoentreno.length];
    fecha = new String[EntrenamientoCargado.fechaentreno.length];
    pesos = EntrenamientoCargado.pesoentreno;
    fecha = EntrenamientoCargado.fechaentreno;
    ///////////////77

    Date fechaDate = null;

    int n = pesos.length;
    Calendar calendar = Calendar.getInstance();

    for (int i = 0; i < n; i++) {
        // JOptionPane.showMessageDialog(null, "fecha tio:"+fecha[i]);
        try {
            fechaDate = formato.parse(fecha[i]);
            calendar.setTime(fechaDate);
        } catch (ParseException ex) {

        }
        //  JOptionPane.showMessageDialog(null, calendar.get(Calendar.DAY_OF_MONTH)+" "+calendar.get(Calendar.MONTH)+1+" "+ calendar.get(Calendar.YEAR));
        s1.add(new Day(calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.MONTH) + 1,
                calendar.get(Calendar.YEAR)), pesos[i]);
        // System.out.print(x[i]+"-"+i+" ");
    }
    datos.addSeries(s1);
    grafica = ChartFactory.createTimeSeriesChart("Progreso de cargas", "Fecha", "Peso", datos, true, true,
            false);
    /// 
    grafica.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) grafica.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);

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

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

}

From source file:Perfil_Deportivo.graficaProgCargas.java

public graficaProgCargas() {
    datos.removeAllSeries();/*from  w  ww. j a  v a  2 s  .  c  o  m*/
    //sxy.add(x[0], y[0]);
    pesos = new double[Progresiones_cargas.pesoentreno.length];
    fecha = new String[Progresiones_cargas.fechaentreno.length];
    pesos = Progresiones_cargas.pesoentreno;
    fecha = Progresiones_cargas.fechaentreno;
    ///////////////77

    Date fechaDate = null;

    int n = pesos.length;
    Calendar calendar = Calendar.getInstance();

    for (int i = 0; i < n; i++) {
        // JOptionPane.showMessageDialog(null, "fecha tio:"+fecha[i]);
        try {
            fechaDate = formato.parse(fecha[i]);
            calendar.setTime(fechaDate);
        } catch (ParseException ex) {

        }
        //  JOptionPane.showMessageDialog(null, calendar.get(Calendar.DAY_OF_MONTH)+" "+calendar.get(Calendar.MONTH)+1+" "+ calendar.get(Calendar.YEAR));
        s1.add(new Day(calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.MONTH) + 1,
                calendar.get(Calendar.YEAR)), pesos[i]);
        // System.out.print(x[i]+"-"+i+" ");
    }
    datos.addSeries(s1);
    grafica = ChartFactory.createTimeSeriesChart("Progreso de cargas", "Fecha", "Peso", datos, true, true,
            false);
    /// 
    grafica.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) grafica.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);

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

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

}

From source file:imc.graficaIMC.java

public graficaIMC() {
    TimeSeries s1 = new TimeSeries("REGISTRO DE IMC ");
    datos.removeAllSeries();// www.j  a  v  a2  s  .c o m
    //sxy.add(x[0], y[0]);
    pesos = new double[imc.imc.length];
    fecha = new String[imc.fecha.length];
    pesos = imc.imc;
    fecha = imc.fecha;
    ///////////////77

    Date fechaDate = null;

    int n = pesos.length;
    Calendar calendar = Calendar.getInstance();

    for (int i = 0; i < n; i++) {
        // JOptionPane.showMessageDialog(null, "fecha tio:"+fecha[i]);
        try {
            fechaDate = formato.parse(fecha[i]);
            calendar.setTime(fechaDate);
        } catch (ParseException ex) {

        }
        //  JOptionPane.showMessageDialog(null, calendar.get(Calendar.DAY_OF_MONTH)+" "+calendar.get(Calendar.MONTH)+1+" "+ calendar.get(Calendar.YEAR));
        s1.add(new Day(calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.MONTH) + 1,
                calendar.get(Calendar.YEAR)), pesos[i]);
        // System.out.print(x[i]+"-"+i+" ");
    }
    datos.addSeries(s1);
    grafica = ChartFactory.createTimeSeriesChart("Progreso de MCM", "Fecha", "IMC", datos, true, true, false);
    /// 
    grafica.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) grafica.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);

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

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

}