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

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

Introduction

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

Prototype

public void setRangeAxisLocation(AxisLocation location) 

Source Link

Document

Sets the location of the primary range axis and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:com.googlecode.logVisualizer.chart.VerticalXYBarChartBuilder.java

private JFreeChart createChart(final IntervalXYDataset dataset) {
    final JFreeChart chart = ChartFactory.createXYBarChart(getTitle(), xLable, false, yLable, dataset,
            PlotOrientation.VERTICAL, isIncludeLegend(), true, false);
    final XYPlot plot = (XYPlot) chart.getPlot();
    final NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();

    double lastXValue = 0;
    if (dataset.getSeriesCount() > 0)
        lastXValue = dataset.getXValue(0, dataset.getItemCount(0) - 1);

    plot.setDomainAxis(new FixedZoomNumberAxis(lastXValue));
    plot.setNoDataMessage("No data available");
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.black);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    setBarShadowVisible(chart, false);/*from   ww w. ja  va 2s . co m*/

    plot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    if (dataset.getSeriesCount() > 0)
        plot.getDomainAxis().setUpperBound(lastXValue);
    plot.getDomainAxis().setLowerBound(0);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    yAxis.setUpperMargin(0.1);

    return chart;
}

From source file:grafix.graficos.eixos.Eixo.java

protected void configurarPlot(final XYPlot plot) {
    NumberAxis nAxis = definirEixoVertical();
    plot.setRangeAxis(nAxis);//from  w w w .  j a  v  a  2s  . c o  m
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinesVisible(this.isGradeHorizontal());
    plot.setRangeGridlinePaint(this.getCorGradeHorizontal());
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
    incluirLegenda(plot);
    incluirEixoX(plot);
    configurarEscalaVertical(plot);
}

From source file:org.jstockchart.plot.TimeseriesPlot.java

private XYPlot createVolumePlot() {
    Font axisFont = new Font("Arial", 0, 12);
    Stroke stroke = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.CAP_SQUARE, 0.0f,
            new float[] { 1.0f, 1.0f }, 1.0f);
    VolumeArea volumeArea = timeseriesArea.getVolumeArea();
    LogicNumberAxis logicVolumeAxis = volumeArea.getLogicVolumeAxis();
    Color volumeColor = new Color(86, 126, 160);
    volumeArea.setVolumeColor(volumeColor);
    CFXNumberAxis volumeAxis = new CFXNumberAxis(logicVolumeAxis.getLogicTicks());
    volumeAxis.setAxisLineVisible(false);
    volumeAxis.setCustomTickCount(2);/*from  www  . j a v a  2s .c  om*/
    volumeAxis.setTickLabelPaint(volumeColor);
    volumeAxis.setUpperBound(logicVolumeAxis.getUpperBound());
    volumeAxis.setTickLabelFont(axisFont);
    volumeAxis.setTickMarkStroke(stroke);
    volumeAxis.setLowerBound(logicVolumeAxis.getLowerBound());
    volumeAxis.setAutoRangeIncludesZero(true);
    XYAreaRenderer2 volumeRenderer = new XYAreaRenderer2();
    volumeRenderer.setSeriesPaint(0, volumeArea.getVolumeColor());
    //volumeRenderer.setShadowVisible(false);
    volumeRenderer.setSeriesStroke(0, stroke);
    volumeRenderer.setBaseStroke(stroke);
    XYPlot plot = new XYPlot(new TimeSeriesCollection(dataset.getVolumeTimeSeries()), null, volumeAxis,
            volumeRenderer);
    plot.setBackgroundPaint(volumeArea.getBackgroudColor());
    plot.setOrientation(volumeArea.getOrientation());
    plot.setRangeAxisLocation(volumeArea.getVolumeAxisLocation());
    plot.setRangeMinorGridlinesVisible(false);

    Stroke outLineStroke = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.CAP_SQUARE, 0.0f,
            new float[] { 1.0f, 1.0f }, 1.0f);
    Stroke gridLineStroke = new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f,
            new float[] { 2.0f, 2.0f }, 1.0f);
    // plot.setBackgroundPaint(Color.RED);
    plot.setRangeGridlineStroke(gridLineStroke);
    plot.setDomainGridlineStroke(gridLineStroke);
    plot.setRangeGridlinesVisible(true);
    plot.setDomainGridlinesVisible(true);
    plot.setOutlineVisible(true);
    plot.setOutlineStroke(outLineStroke);
    plot.setOutlinePaint(Color.black);
    plot.setRangeZeroBaselineVisible(true);
    return plot;
}

From source file:ch.agent.crnickl.demo.stox.Chart.java

private XYPlot getBarPlot() throws KeyedException {
    // use a number axis on the right side with a special formatter for millions
    NumberAxis axis = new NumberAxis();
    axis.setAutoRangeIncludesZero(false);
    axis.setNumberFormatOverride(new NumberFormatForMillions());
    XYPlot plot = new XYPlot(null, null, axis, null);
    plot.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT);
    return plot;/*  w w  w .ja  v  a  2s  .  co m*/
}

From source file:ca.nengo.plot.impl.DefaultPlotter.java

private void doPlot(float[] x, float[][] ideal, float[][] actual, int dim) {
    XYSeriesCollection dataset = new XYSeriesCollection();

    XYSeries idealSeries = new XYSeries("Ideal");
    for (int i = 0; i < x.length; i++) {
        idealSeries.add(x[i], ideal[i][dim]);
    }// w w  w .  j ava2 s  .c  o m
    dataset.addSeries(idealSeries);

    XYSeries actualSeries = new XYSeries("Actual");
    for (int i = 0; i < x.length; i++) {
        actualSeries.add(x[i], actual[i][dim]);
    }
    dataset.addSeries(actualSeries);

    JFreeChart chart = ChartFactory.createXYLineChart("Distortion", "X", "Estimate", dataset,
            PlotOrientation.VERTICAL, true, false, false);

    XYSeries errorSeries = new XYSeries("Error");
    float[][] error = MU.difference(actual, ideal);
    for (int i = 0; i < x.length; i++) {
        //         errorSeries.add(x[i], actual[i][dim] - ideal[i][dim]);
        errorSeries.add(x[i], error[i][dim]);
    }
    XYSeriesCollection errorDataset = new XYSeriesCollection();
    errorDataset.addSeries(errorSeries);
    NumberAxis errorAxis = new NumberAxis("Error");
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRangeAxis(1, errorAxis);
    plot.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT);
    plot.setDataset(1, errorDataset);
    plot.mapDatasetToRangeAxis(1, 1);
    XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
    plot.setRenderer(1, renderer);

    float[] err = MU.transpose(error)[dim];
    float mse = MU.prod(err, err) / (float) err.length;
    showChart(chart, "Distortion Error Plot (MSE=" + mse + ")");
}

From source file:org.matsim.integration.weekly.fundamentaldiagram.CreateAutomatedFDTest.java

private void scatterPlot(Map<Double, Map<String, Tuple<Double, Double>>> inputData, String outFile) {

    String mode1 = travelModes[0];
    XYSeries carFlow = new XYSeries(mode1 + " flow");
    XYSeries carSpeed = new XYSeries(mode1 + " speed");

    XYSeries bikeFlow = null;/*from  www  .  java2  s.co  m*/
    XYSeries bikeSpeed = null;

    if (travelModes.length == 2) {
        bikeFlow = new XYSeries(travelModes[1] + " flow");
        bikeSpeed = new XYSeries(travelModes[1] + " speed");
    }

    for (double d : inputData.keySet()) {
        carFlow.add(d, inputData.get(d).get(mode1).getFirst());
        carSpeed.add(d, inputData.get(d).get(mode1).getSecond());

        if (travelModes.length == 2) {
            bikeFlow.add(d, inputData.get(d).get(travelModes[1]).getFirst());
            bikeSpeed.add(d, inputData.get(d).get(travelModes[1]).getSecond());
        }
    }

    // flow vs density
    XYSeriesCollection flowDataset = new XYSeriesCollection();
    flowDataset.addSeries(carFlow);

    NumberAxis flowAxis = new NumberAxis("Flow (PCU/h)");
    flowAxis.setRange(0.0, 1700.0);

    XYPlot plot1 = new XYPlot(flowDataset, null, flowAxis, new XYLineAndShapeRenderer(false, true));
    plot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    // speed vs density
    XYSeriesCollection speedDataset = new XYSeriesCollection();
    speedDataset.addSeries(carSpeed);

    if (travelModes.length == 2) {
        flowDataset.addSeries(bikeFlow);
        speedDataset.addSeries(bikeSpeed);
    }

    NumberAxis speedAxis = new NumberAxis("Speed (m/s)");
    speedAxis.setRange(0.0, 17.0);

    XYPlot plot2 = new XYPlot(speedDataset, null, speedAxis, new XYLineAndShapeRenderer(false, true));
    plot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    NumberAxis densityAxis = new NumberAxis("Overall density (PCU/km)");
    densityAxis.setRange(0.0, 140.00);

    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(densityAxis);
    plot.setGap(10.);
    plot.add(plot1);
    plot.add(plot2);
    plot.setOrientation(PlotOrientation.VERTICAL);

    JFreeChart chart = new JFreeChart("Fundamental diagrams", JFreeChart.DEFAULT_TITLE_FONT, plot, true);

    try {
        ChartUtilities.saveChartAsPNG(new File(outFile), chart, 800, 600);
    } catch (IOException e) {
        throw new RuntimeException("Data is not plotted. Reason " + e);
    }
}

From source file:org.glotaran.core.datadisplayers.multispec.MultiSpecEditorTopComponent.java

private JFreeChart createXYPlot(PlotOrientation orient, AxisLocation axLoc, double[] axisValues, JPanel panel,
        boolean domInvert, CrosshairOverlay overlay) {
    JFreeChart subchart;/*from ww w.j  av a  2 s .c  om*/
    XYSeriesCollection chartDataset = new XYSeriesCollection();
    subchart = ChartFactory.createXYLineChart(null, null, null, chartDataset, orient, false, false, false);
    if (axisValues[axisValues.length - 1] < axisValues[0]) {
        subchart.getXYPlot().getDomainAxis().setUpperBound(axisValues[0]);
        subchart.getXYPlot().getDomainAxis().setInverted(domInvert);
    } else {
        subchart.getXYPlot().getDomainAxis().setUpperBound(axisValues[axisValues.length - 1]);
    }

    XYPlot plot = (XYPlot) subchart.getPlot();
    plot.getDomainAxis().setLowerMargin(0.0);
    plot.getDomainAxis().setUpperMargin(0.0);
    plot.getDomainAxis().setAutoRange(true);
    plot.setDomainAxisLocation(axLoc);
    plot.setRangeAxisLocation(axLoc);
    plot.getDomainAxis().setInverted(domInvert);

    GraphPanel subchartPanel = new GraphPanel(subchart);
    if (overlay != null) {
        subchartPanel.addOverlay(overlay);
    }
    panel.removeAll();
    panel.setLayout(new BorderLayout());
    subchartPanel.setMinimumDrawHeight(0);
    subchartPanel.setMinimumDrawWidth(0);
    panel.add(subchartPanel);
    return subchart;

}

From source file:qmul.align.AlignmentTester.java

/**
 * Plot a turn vs score chart with arbitrary subplots
 * /*w ww .  j a  va  2 s .  co m*/
 * @param scores1
 * @param title
 */
private void plotScores(String title, List<Double>... scores) {
    ApplicationFrame af = new ApplicationFrame(title);
    final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis());
    plot.setGap(10.0);

    for (int i = 0; i < scores.length; i++) {

        final XYSeries series = new XYSeries("Coherence scores " + i);
        for (int x = 0; x < scores[i].size(); x++) {
            series.add(x, scores[i].get(x));
        }
        XYSeriesCollection data = new XYSeriesCollection(series);
        XYPlot subplot = new XYPlot(data, null, new NumberAxis(), new StandardXYItemRenderer());
        subplot.setRangeAxisLocation(i == 0 ? AxisLocation.TOP_OR_LEFT : AxisLocation.BOTTOM_OR_LEFT);
        plot.add(subplot, 1);
    }

    plot.setOrientation(PlotOrientation.VERTICAL);
    final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(1000, 500));
    af.setContentPane(chartPanel);
    af.pack();
    RefineryUtilities.centerFrameOnScreen(af);
    af.setVisible(true);
}

From source file:com.att.aro.diagnostics.GraphPanel.java

/**
 * Sets up the CPU plot//  w  ww  .j a  v  a  2s.  c  o m
 * 
 * @return plot CPU plot
 */
private static XYPlot createCpuPlot() {

    // Set up renderer
    StandardXYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES);
    renderer.setAutoPopulateSeriesShape(false);
    renderer.setBaseShape(CPU_PLOT_POINT_SHAPE);
    renderer.setSeriesPaint(0, Color.black);

    // Normalize the throughput axis so that it represents max value
    NumberAxis axis = new NumberAxis();
    axis.setVisible(false);
    axis.setAutoRange(false);
    axis.setRange(MIN_CPU_USAGE, MAX_CPU_USAGE);

    // Create plot
    XYPlot plot = new XYPlot(null, null, axis, renderer);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    plot.getRangeAxis().setVisible(false);

    return plot;
}

From source file:com.att.aro.diagnostics.GraphPanel.java

/**
 * Returns a XYPlot for Radio info/*w  ww.  j a  v  a  2 s.  c  o  m*/
 * 
 * @return XYPlot.
 */
private static XYPlot createRadioPlot() {

    // Set up renderer
    StandardXYItemRenderer radioRenderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES);
    radioRenderer.setAutoPopulateSeriesShape(false);
    radioRenderer.setBaseShape(DEFAULT_POINT_SHAPE);
    radioRenderer.setSeriesPaint(0, Color.red);

    // Normalize the throughput axis so that it represents max value
    NumberAxis axis = new NumberAxis();
    axis.setVisible(false);
    axis.setAutoRange(false);
    axis.setRange(MIN_SIGNAL, MAX_SIGNAL);

    // Create plot
    XYPlot radioPlot = new XYPlot(null, null, axis, radioRenderer);
    radioPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    radioPlot.getRangeAxis().setVisible(false);

    return radioPlot;

}