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

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

Introduction

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

Prototype

public ValueAxis getRangeAxis() 

Source Link

Document

Returns the range axis for the plot.

Usage

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

/**
 * Creates a chart.//from   ww w. j  ava 2s  .c o m
 * 
 * @param dataset  the dataset.
 * 
 * @return a chart.
 */
private JFreeChart createChart(final XYDataset dataset) {

    final JFreeChart chart = ChartFactory.createTimeSeriesChart("Time Series Demo 6", "Date", "Value", dataset,
            true, true, false);

    final XYPlot plot = chart.getXYPlot();
    final DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    final ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setAutoRangeMinimumSize(1.0);
    return chart;

}

From source file:com.itemanalysis.jmetrik.graph.nicc.NonparametricCurvePanel.java

public void updateDatasetFor(String name, double min, double max, XYDataset dataset) {
    JFreeChart c = charts.get(name);//from   w w w  .j ava2s.c o  m
    XYPlot plot = (XYPlot) c.getPlot();
    plot.setDataset(dataset);
    setXYPlotRenderer(plot);

    ValueAxis axis = plot.getRangeAxis();
    axis.setLowerBound(min);
    axis.setUpperBound(max);

}

From source file:visualizer.projection.distance.view.DistanceHistogram.java

private JFreeChart createChart(IntervalXYDataset intervalxydataset) {
    JFreeChart chart = ChartFactory.createHistogram("Distance Histogram", "Distances Values", "Occurences",
            intervalxydataset, PlotOrientation.VERTICAL, true, true, false);

    //        JFreeChart chart = ChartFactory.createHistogram("Histograma das Distncias",
    //                "Valores", "Ocorrncias", intervalxydataset,
    //                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);

    XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer();
    xybarrenderer.setDrawBarOutline(false);

    return chart;
}

From source file:sim.app.sugarscape.Charts.java

JFreeChart createGiniChart() {
    JFreeChart chart3 = ChartFactory.createXYLineChart("Lorenz Curve", "Population Percentage",
            "Percentage of Total Wealth", new XYSeriesCollection(model.lorenz_curve), PlotOrientation.VERTICAL,
            true, true, false);//from   w  w w.ja  v  a 2s .  c  o  m
    XYPlot plot = chart3.getXYPlot();
    ValueAxis yAxis = plot.getRangeAxis();
    //xAxis.setFixedDimension(100);
    yAxis.setFixedDimension(1.0);
    //yAxis.setRange(0,1);
    ValueAxis xAxis = plot.getDomainAxis();
    xAxis.setFixedDimension(50);

    //StandardXYItemRenderer 
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, Color.black);
    NumberAxis axis2 = new NumberAxis("Average Agent Vision");

    //axis2.setAutoRangeIncludesZero(false);
    axis2.setRange(0, 12);
    plot.setRangeAxis(1, axis2);
    plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);
    //XYSeriesCollection vision = new XYSeriesCollection(lorenz_agent_vision);
    //plot.setDataset(1, vision);
    return chart3;
}

From source file:DynamiskDemo2.java

/**
 * Creates a sample chart.//from w  w  w .  ja  v  a 2s.co m
 * 
 * @param dataset  the dataset.
 * 
 * @return A sample chart.
 */
private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createXYLineChart("Dynamic Data Demo", "Time", "Value", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    final XYPlot plot = result.getXYPlot();
    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);
    axis.setFixedAutoRange(60000.0); // 60 seconds
    axis = plot.getRangeAxis();
    axis.setRange(-0.5, 1.5);
    return result;
}

From source file:org.jfree.expdemo.SelectionDemo2.java

private static JFreeChart createChart(XYDataset dataset, DatasetSelectionExtension ext) {
    JFreeChart chart = ChartFactory.createScatterPlot("SelectionDemo2", "X", "Y", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setNoDataMessage("NO DATA");

    plot.setDomainPannable(true);//from w w  w  . j  a v a  2 s . co m
    plot.setRangePannable(true);
    plot.setDomainZeroBaselineVisible(true);
    plot.setRangeZeroBaselineVisible(true);

    plot.setDomainGridlineStroke(new BasicStroke(0.0f));
    plot.setRangeGridlineStroke(new BasicStroke(0.0f));

    plot.setDomainMinorGridlinesVisible(true);
    plot.setRangeMinorGridlinesVisible(true);

    XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer();
    r.setSeriesFillPaint(0, r.lookupSeriesPaint(0));
    r.setSeriesFillPaint(1, r.lookupSeriesPaint(1));
    r.setSeriesFillPaint(2, r.lookupSeriesPaint(2));
    r.setUseFillPaint(true);

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);

    domainAxis.setTickMarkInsideLength(2.0f);
    domainAxis.setTickMarkOutsideLength(2.0f);

    domainAxis.setMinorTickCount(2);
    domainAxis.setMinorTickMarksVisible(true);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setTickMarkInsideLength(2.0f);
    rangeAxis.setTickMarkOutsideLength(2.0f);
    rangeAxis.setMinorTickCount(2);
    rangeAxis.setMinorTickMarksVisible(true);

    //add selection specific rendering
    IRSUtilities.setSelectedItemFillPaint(r, ext, Color.white);

    //register plot as selection change listener
    ext.addSelectionChangeListener(plot);

    return chart;
}

From source file:com.charts.FiveDayChart.java

public FiveDayChart(YStockQuote currentStock) {
    TimeSeries series = new TimeSeries(currentStock.get_name());
    ArrayList<String> fiveDayData = currentStock.get_five_day_data();
    int length = fiveDayData.size();
    for (int i = 22; i < length; i += 5) {
        String[] data = fiveDayData.get(i).split(",");
        Date time = new Date((long) Integer.parseInt(data[0]) * 1000);
        DateFormat df = new SimpleDateFormat("MM-dd-yyyy-h-m");
        series.addOrUpdate(new Minute(time), Double.parseDouble(data[1]));
    }//from   w  w w.j av a2s .  co m
    String[] data = fiveDayData.get(length - 1).split(",");
    Date time = new Date((long) Integer.parseInt(data[0]) * 1000);
    DateFormat df = new SimpleDateFormat("MM-dd-yyyy-h-m");
    series.addOrUpdate(new Minute(time), Double.parseDouble(data[1]));

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(series);
    JFreeChart chart = ChartFactory.createTimeSeriesChart(
            currentStock.get_name() + "(" + currentStock.get_symbol() + ")" + " Five Day", "Date", "Price",
            dataset, true, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    ValueAxis yAxis = (ValueAxis) plot.getRangeAxis();

    DateAxis xAxis = (DateAxis) plot.getDomainAxis();
    Date now = new Date();
    SegmentedTimeline segmentedTimeline = SegmentedTimeline.newFifteenMinuteTimeline();
    segmentedTimeline.addBaseTimelineExclusions(segmentedTimeline.getStartTime(), now.getTime());
    Calendar[][] holidays = DayRange.getHolidayDates();
    for (int i = 0; i < holidays[0].length; i++) {
        Calendar day = Calendar.getInstance();
        day.set(Calendar.YEAR, holidays[0][i].get(Calendar.YEAR));
        day.set(Calendar.MONTH, holidays[0][i].get(Calendar.MONTH));
        day.set(Calendar.DAY_OF_MONTH, holidays[0][i].get(Calendar.DAY_OF_MONTH));
        day.set(Calendar.HOUR_OF_DAY, 9);
        segmentedTimeline.addException(day.getTimeInMillis(), day.getTimeInMillis() + 21600000);
    }
    xAxis.setTimeline(segmentedTimeline);
    xAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    //xAxis.setVerticalTickLabels(true);
    xAxis.setDateFormatOverride(new SimpleDateFormat("MM-dd"));
    xAxis.setAutoTickUnitSelection(false);
    xAxis.setAutoRange(false);

    StandardXYItemRenderer renderer1 = new StandardXYItemRenderer();
    renderer1.setSeriesPaint(0, Color.BLUE);
    TimeSeries movingAverage5 = MovingAverage.createMovingAverage(series, "MA(5)", 30, 0);
    Double currMA5 = (Double) movingAverage5.getDataItem(movingAverage5.getItemCount() - 1).getValue();
    currMA5 = Math.round(currMA5 * 100.0) / 100.0;
    movingAverage5.setKey("MA(5): " + currMA5);
    TimeSeriesCollection collection = new TimeSeriesCollection();
    collection.addSeries(movingAverage5);
    plot.setDataset(1, collection);
    plot.setRenderer(1, renderer1);

    plot.setBackgroundPaint(Color.WHITE);

    chartPanel = new ChartPanel(chart);
    chart.setBackgroundPaint(chartPanel.getBackground());
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);
    chartPanel.setVisible(true);
    chartPanel.revalidate();
    chartPanel.repaint();
}

From source file:CorrelationLambdaTest.java

@Test

public void crossCorrelationGraphicTest() {

    CategoryTableXYDataset serie = new CategoryTableXYDataset();
    serie.setNotify(false);/*from  ww  w. j av  a  2s. c  om*/
    double step = 1.0 / discretization;
    double startPosition = step * framePosition;
    //100 ? - 100 , 50 ? - 50 , 25 ?- 25 
    Transform t = new Transform(new FastWaveletTransform(new Haar1()));
    double[] signal = testData.get1DSimpleSignal(1.5, 500, 32768, 5000);
    double[] data = crossCorrelationCoefficient(signal, window);

    //        double[] data = math.convolve(testData.get1DSignal(100, 200, frameWidth, discretization), math.lpf(70, step, 128));

    //        double[] data = math.convolve(testData.get1DSignal(100, 200, 32768, 10000), math.lpf(70, 1./10000, 32));
    //        double[] data = testData.get1DSignal(100, 200, frameWidth, discretization);
    //        double[] data = math.lpf(70, step,128);
    for (int i = 0; i < data.length; i++) {
        serie.add(startPosition, data[i], "");
        startPosition += step;
    }
    JFreeChart chart = ChartFactory.createXYLineChart("", "t,c", "wave", serie);
    chart.removeLegend();
    chart.setAntiAlias(false);

    XYPlot plot = chart.getXYPlot();
    //plot.setRangeGridlinePaint(Color.BLACK);
    org.jfree.chart.axis.ValueAxis yAxis = plot.getRangeAxis();
    org.jfree.chart.axis.ValueAxis xAxis = plot.getDomainAxis();
    double start = framePosition * 1.0 / discretization;
    double max = start + frameWidth * 1.0 / discretization;
    xAxis.setRange(start, max);
    ChartPanel chartPanel = new ChartPanel(chart);

    JPanel p = new JPanel(new BorderLayout());

    p.removeAll();
    p.add(chartPanel);
    p.validate();
    //1. Create the frame.
    JFrame frame = new JFrame("FrameDemo");

    //2. Optional: What happens when the frame closes?
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //3. Create components and put them in the frame.
    //...create emptyLabel...
    frame.getContentPane().add(new Label("olol"), BorderLayout.CENTER);
    frame.getContentPane().add(p, BorderLayout.CENTER);

    //4. Size the frame.
    frame.pack();

    //5. Show it.
    frame.setVisible(true);
}

From source file:DynamicDataDemo.java

/**
 * Creates a sample chart.//from  w w  w .ja v  a  2s  . co m
 * 
 * @param dataset  the dataset.
 * 
 * @return A sample chart.
 */
private JFreeChart createChart(final XYDataset dataset, String title, String xcoor, String ycoor) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart(title, xcoor, ycoor, dataset, true, true,
            false);
    final XYPlot plot = result.getXYPlot();
    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);
    axis.setFixedAutoRange(60000.0); // 60 seconds
    axis = plot.getRangeAxis();
    axis.setRange(0.0, 500.0);
    return result;
}

From source file:com.experiments.DynamicDataDemo.java

/**
 * Creates a sample chart.//w  ww.  j  a  v a2  s. c  om
 * 
 * @param dataset
 *            the dataset.
 * 
 * @return A sample chart.
 */
private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart("Dynamic Data Demo", "Time", "Value", dataset,
            true, true, false);
    final XYPlot plot = result.getXYPlot();
    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);
    axis.setFixedAutoRange(60000.0); // 60 seconds
    axis = plot.getRangeAxis();
    axis.setRange(0.0, 200.0);
    axis.setVisible(false);
    return result;
}