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

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

Introduction

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

Prototype

public void setRangeAxis(ValueAxis axis) 

Source Link

Document

Sets the range axis for the plot and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:playground.dgrether.analysis.charts.DgAvgDeltaUtilsGroupChart.java

public JFreeChart createChart() {
    XYPlot plot = new XYPlot();
    ValueAxis xAxis = this.axisBuilder.createValueAxis("Income [Chf / Year]");
    ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Utils [Utils]");
    plot.setDomainAxis(xAxis);//from   w  ww  .j  ava  2 s.  c  om
    plot.setRangeAxis(yAxis);

    DgColorScheme colorScheme = new DgColorScheme();

    XYItemRenderer renderer2;
    renderer2 = new XYLineAndShapeRenderer(true, true);
    renderer2.setSeriesItemLabelsVisible(0, true);
    renderer2.setSeriesItemLabelGenerator(0, this.labelGenerator);
    plot.setDataset(0, this.dataset);
    renderer2.setSeriesStroke(0, new BasicStroke(2.0f));
    renderer2.setSeriesOutlineStroke(0, new BasicStroke(3.0f));
    renderer2.setSeriesPaint(0, colorScheme.getColor(1, "a"));
    plot.setRenderer(0, renderer2);

    JFreeChart chart = new JFreeChart("", plot);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.getLegend().setItemFont(this.axisBuilder.getAxisFont());
    chart.setTextAntiAlias(true);
    return chart;
}

From source file:playground.dgrether.analysis.charts.DgAvgDeltaUtilsModeQuantilesChart.java

@Override
public JFreeChart createChart() {
    XYPlot plot = new XYPlot();
    ValueAxis xAxis = this.axisBuilder.createValueAxis("% of Population Sorted by Income");
    xAxis.setRange(0.0, 102.0);/*from w w  w  . j av a2 s .c o m*/
    ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Utils [Utils]");
    yAxis.setRange(-0.05, 0.3);
    plot.setDomainAxis(xAxis);
    plot.setRangeAxis(yAxis);

    DgColorScheme colorScheme = new DgColorScheme();

    XYItemRenderer renderer2;
    renderer2 = new XYLineAndShapeRenderer(true, true);
    plot.setDataset(0, this.dataset);
    for (int i = 0; i <= 3; i++) {
        renderer2.setSeriesStroke(i, new BasicStroke(2.0f));
        renderer2.setSeriesOutlineStroke(i, new BasicStroke(3.0f));
        renderer2.setSeriesPaint(i, colorScheme.getColor(i + 1, "a"));
    }
    plot.setRenderer(0, renderer2);

    JFreeChart chart = new JFreeChart("", plot);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.getLegend().setItemFont(this.axisBuilder.getAxisFont());
    chart.setTextAntiAlias(true);
    return chart;
}

From source file:org.sonar.server.charts.deprecated.SparkLinesChart.java

private void configurePlot() {
    XYPlot plot = (XYPlot) jfreechart.getPlot();
    plot.setInsets(RectangleInsets.ZERO_INSETS);
    plot.setDataset(dataset);/*w  ww  . ja  va  2  s  .  co m*/
    plot.setDomainAxis(x);
    plot.setDomainGridlinesVisible(false);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeGridlinesVisible(false);
    plot.setRangeCrosshairVisible(false);
    plot.setRangeAxis(y);
    plot.setRenderer(renderer);
    plot.setBackgroundAlpha(0.0f);
}

From source file:org.usfirst.frc.team2084.neuralnetwork.HeadingNeuralNetworkTrainer.java

public HeadingNeuralNetworkTrainer() {
    outputGraphNetworkSeries = new XYSeries("Network Prediction");
    outputGraphDataSeries = new XYSeries("Error");
    final XYSeriesCollection data = new XYSeriesCollection();
    data.addSeries(outputGraphDataSeries);
    data.addSeries(outputGraphNetworkSeries);
    outputGraph = ChartFactory.createXYLineChart("Error vs. Output", "Time", "Error", data,
            PlotOrientation.VERTICAL, true, true, false);

    NumberAxis xAxis = new NumberAxis();
    xAxis.setRange(new Range(-Math.PI, Math.PI));
    xAxis.setAutoRange(false);/*ww  w. j  av a2 s. c om*/
    NumberAxis yAxis = new NumberAxis();
    yAxis.setRange(new Range(-1, 1));

    XYPlot plot = (XYPlot) outputGraph.getPlot();
    plot.setDomainAxis(xAxis);
    plot.setRangeAxis(yAxis);

    network = new Network(new int[] { 1, 5, 1 }, eta, momentum, new TransferFunction.HyperbolicTangent());

    try {
        SwingUtilities.invokeAndWait(() -> {
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            final Container content = frame.getContentPane();
            content.setLayout(new BorderLayout());

            outputGraphPanel = new ChartPanel(outputGraph);
            outputGraphPanel.setDomainZoomable(false);
            outputGraphPanel.setRangeZoomable(false);
            graphPanel.add(outputGraphPanel);

            graphPanel.setLayout(new GridLayout(1, 1));
            content.add(graphPanel, BorderLayout.CENTER);
            {

                JLabel etaLabel = new JLabel("Eta:");
                etaLabel.setLabelFor(etaField);
                etaField.setText(Double.toString(network.getEta()));
                etaField.setColumns(5);
                etaField.addPropertyChangeListener("value",
                        (evt) -> eta = ((Number) evt.getNewValue()).doubleValue());
                controlPanel.add(etaLabel);
                controlPanel.add(etaField);

                JLabel momentumLabel = new JLabel("Momentum:");
                momentumLabel.setLabelFor(etaField);
                momentumField.setText(Double.toString(network.getMomentum()));
                momentumField.setColumns(5);
                momentumField.addPropertyChangeListener("value",
                        (evt) -> momentum = ((Number) evt.getNewValue()).doubleValue());
                controlPanel.add(momentumLabel);
                controlPanel.add(momentumField);

                JLabel iterationsLabel = new JLabel("Iterations:");
                iterationsLabel.setLabelFor(iterationsField);
                iterationsField.setText(Integer.toString(iterations));
                iterationsField.setColumns(10);
                iterationsField.addPropertyChangeListener("value",
                        (evt) -> iterations = ((Number) evt.getNewValue()).intValue());
                controlPanel.add(iterationsLabel);
                controlPanel.add(iterationsField);
            }

            chooseDataButton.addActionListener((e) -> {
                if (dataDirectoryChooser.showOpenDialog(frame) == JFileChooser.APPROVE_OPTION) {
                    dataDirectory = dataDirectoryChooser.getSelectedFile();
                    displayData();
                }
            });
            controlPanel.add(chooseDataButton);

            trainButton.addActionListener((e) -> trainNetwork());
            controlPanel.add(trainButton);

            saveButton.addActionListener((e) -> {
                saveNetwork();
            });
            controlPanel.add(saveButton);

            content.add(controlPanel, BorderLayout.SOUTH);

            dataDirectoryChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
            frame.setVisible(true);
        });
    } catch (InvocationTargetException | InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:uk.co.petertribble.jkstat.gui.KstatBaseChart.java

/**
 * Set up the X and Y axes./*  w w w .jav  a 2  s . c  om*/
 */
public void setAxes() {
    XYPlot xyplot = chart.getXYPlot();

    String ylabel = showdelta ? KstatResources.getString("CHART.RATE")
            : KstatResources.getString("CHART.VALUE");
    NumberAxis loadaxis = new NumberAxis(ylabel);
    loadaxis.setAutoRange(true);
    loadaxis.setAutoRangeIncludesZero(true);
    xyplot.setRangeAxis(loadaxis);

    DateAxis daxis = new DateAxis(KstatResources.getString("CHART.TIME"));
    daxis.setAutoRange(true);
    // let a sequnce show its full date range
    if (!(jkstat instanceof SequencedJKstat)) {
        daxis.setFixedAutoRange(maxage);
    }
    xyplot.setDomainAxis(daxis);
}

From source file:org.yooreeka.util.gui.XyGui.java

public XyGui(String title, double[] x) {

    super(title);

    errMsg = new StringBuilder();
    setLoopInt(x.length);/*from  www  .  j  a v  a  2  s.  c om*/

    if (checkX(x)) {

        XYSeries xydata = new XYSeries(title);

        for (int i = 0; i < loopInt; i++) {
            xydata.add(x[i], C.ZERO_DOUBLE);
        }

        xycollection = new XYSeriesCollection(xydata);

        final JFreeChart chart = ChartFactory.createXYLineChart(title, "X", "Y", xycollection,
                PlotOrientation.VERTICAL, true, true, false);

        final XYPlot plot = chart.getXYPlot();

        final NumberAxis domainAxis = new NumberAxis("x");
        plot.setDomainAxis(domainAxis);

        final NumberAxis rangeAxis = new NumberAxis("y");
        plot.setRangeAxis(rangeAxis);

        chart.setBackgroundPaint(Color.white);
        plot.setOutlinePaint(Color.black);

        final ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
        setContentPane(chartPanel);

    } else {
        System.err.println(errMsg.toString());
    }
}

From source file:org.yooreeka.util.gui.XyGui.java

public XyGui(String title, double[] x, double[] y) {

    super(title);

    errMsg = new StringBuilder();
    setLoopInt(x.length);/*from  w  w w  .  j a  va 2  s.c om*/

    if (checkX(x) && checkY(x.length, y)) {

        XYSeries xydata = new XYSeries(title);

        for (int i = 0; i < loopInt; i++) {
            xydata.add(x[i], y[i]);
        }

        xycollection = new XYSeriesCollection(xydata);

        final JFreeChart chart = ChartFactory.createXYLineChart(title + " (XY Plot)", "X", "Y", xycollection,
                PlotOrientation.VERTICAL, true, true, false);

        final XYPlot plot = chart.getXYPlot();

        final NumberAxis domainAxis = new NumberAxis("x");
        plot.setDomainAxis(domainAxis);

        final NumberAxis rangeAxis = new NumberAxis("y");
        plot.setRangeAxis(rangeAxis);

        chart.setBackgroundPaint(Color.white);
        plot.setOutlinePaint(Color.black);

        final ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
        setContentPane(chartPanel);

    } else {
        System.err.println(errMsg.toString());
    }
}

From source file:org.yooreeka.util.gui.XyLogGui.java

public XyLogGui(String title, double[] x, double[] y) {

    super(title);

    errMsg = new StringBuilder();
    setLoopInt(x.length);/*from   ww w .  j  av  a2 s .c  o  m*/

    if (checkX(x) && checkY(x.length, y)) {

        XYSeries xydata = new XYSeries(title);

        for (int i = 0; i < loopInt; i++) {

            if (x[i] == C.ZERO_DOUBLE || x[i] < 0) {
                x[i] = C.SMALL_DOUBLE;
            }

            if (y[i] == C.ZERO_DOUBLE || y[i] < 0) {
                y[i] = C.SMALL_DOUBLE;
            }

            xydata.add(x[i], y[i]);
        }

        xycollection = new XYSeriesCollection(xydata);

        final JFreeChart chart = ChartFactory.createXYLineChart(title + " (XY Plot)", "X", "Y", xycollection,
                PlotOrientation.VERTICAL, true, true, false);

        final XYPlot plot = chart.getXYPlot();

        final NumberAxis domainAxis = new NumberAxis("x");
        plot.setDomainAxis(domainAxis);

        final NumberAxis logRangeAxis = new LogarithmicAxis("Log(y)");
        plot.setRangeAxis(logRangeAxis);

        chart.setBackgroundPaint(Color.white);
        plot.setOutlinePaint(Color.black);

        final ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
        setContentPane(chartPanel);

    } else {
        System.err.println(errMsg.toString());
    }
}

From source file:com.att.aro.ui.view.diagnostictab.plot.SpeedThrottlePlot.java

/**
 * @param plot/* w ww.  ja va 2  s .  co  m*/
 * @param seriesDL
 * @param seriesUP
 */
private void setDataPlot(XYPlot plot, XYSeries seriesDL, XYSeries seriesUP) {
    serCollection.addSeries(seriesDL);
    serCollection.addSeries(seriesUP);

    XYStepRenderer renderer = new XYStepRenderer();

    LogAxis rangeAxis = new LogAxis(); // new API 
    rangeAxis.setAutoRange(true);
    rangeAxis.setVisible(false);
    plot.setRangeAxis(rangeAxis);
    plot.setRangePannable(true);
    plot.setRangeCrosshairVisible(true);

    renderer = (XYStepRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setSeriesStroke(0, new BasicStroke(1.0f));
    renderer.setSeriesStroke(1, new BasicStroke(2.5f));
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setSeriesPaint(1, Color.red);
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    renderer.setDefaultEntityRadius(6);

    renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {
        @Override
        public String generateToolTip(XYDataset dataset, int series, int item) {
            StringBuffer displayInfo = new StringBuffer();
            java.lang.Number tempx = dataset.getX(series, item);
            java.lang.Number tempy = dataset.getY(series, item);
            // series 0 -> downstream , stries 1 -> upstream
            String streamInfo = "";
            if (series == 0) {
                streamInfo = ResourceBundleHelper.getMessageString("dlog.collector.option.attenuator.downlink");
            } else {
                streamInfo = ResourceBundleHelper.getMessageString("dlog.collector.option.attenuator.uplink");
            }
            return displayInfo.append("Time: " + tempx + " , " + streamInfo + " : " + tempy + " kbps")
                    .toString();
        }
    });
    plot.setRenderer(renderer);
    plot.setDataset(serCollection);

}

From source file:playground.dgrether.analysis.charts.DgAvgDeltaUtilsQuantilesChart.java

public JFreeChart createChart() {
    XYPlot plot = new XYPlot();
    ValueAxis xAxis = this.axisBuilder.createValueAxis("% of Population Sorted by Income");
    xAxis.setRange(0.0, 102.0);//w  ww .  j  a va 2s. c o  m
    ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Utils [Utils]");
    yAxis.setRange(-0.05, 0.3);
    //      xAxis.setVisible(false);
    //      xAxis.setFixedAutoRange(1.0);
    plot.setDomainAxis(xAxis);
    plot.setRangeAxis(yAxis);

    DgColorScheme colorScheme = new DgColorScheme();

    XYItemRenderer renderer2;
    renderer2 = new XYLineAndShapeRenderer(true, true);
    renderer2.setSeriesItemLabelsVisible(0, true);
    //      renderer2.setSeriesItemLabelGenerator(0, this.labelGenerator);
    plot.setDataset(0, this.dataset);
    renderer2.setSeriesStroke(0, new BasicStroke(2.0f));
    renderer2.setSeriesOutlineStroke(0, new BasicStroke(3.0f));
    renderer2.setSeriesPaint(0, colorScheme.getColor(1, "a"));
    plot.setRenderer(0, renderer2);

    JFreeChart chart = new JFreeChart("", plot);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.getLegend().setItemFont(this.axisBuilder.getAxisFont());
    chart.setTextAntiAlias(true);
    chart.removeLegend();
    return chart;
}