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:umberto.WeightedClusterCoefficient.ChartUtils.java

public static void scaleLogChart(JFreeChart chart, XYSeries dSeries, boolean normalized) {
    XYPlot plot = (XYPlot) chart.getPlot();
    final LogAxis logyAxis = new LogAxis(plot.getRangeAxis().getLabel());
    final LogAxis logxAxis = new LogAxis(plot.getDomainAxis().getLabel());
    //Set y axis format.
    //        DecimalFormat formaty = (DecimalFormat) DecimalFormat.getNumberInstance(Locale.ENGLISH);
    //        formaty.applyPattern("#0.0000");

    //set y axis// w  w  w.j  a  va  2  s.  c  o  m
    logyAxis.setBase(10);
    //        logyAxis.setNumberFormatOverride(formaty);
    logyAxis.setStandardTickUnits(LogAxis.createLogTickUnits(Locale.ENGLISH));
    //        logyAxis.setRange(0.01, 1.0);
    logyAxis.setAutoRange(true);
    plot.setRangeAxis(logyAxis);
    //set x axis
    logxAxis.setBase(10);
    logxAxis.setStandardTickUnits(LogAxis.createLogTickUnits(Locale.ENGLISH));
    logxAxis.setAutoRange(true);
    //logxAxis.setRange(0.00001, 1.0);//Se la voglio zoommare
    plot.setDomainAxis(logxAxis);
}

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

private static JFreeChart createChart(IntervalXYDataset intervalxydataset) {
    JFreeChart jfreechart = ChartFactory.createXYBarChart("RelativeDateFormat Demo 2", "Date ", true,
            "Time To Complete", intervalxydataset, PlotOrientation.VERTICAL, true, 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);
    XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer();
    xybarrenderer.setDrawBarOutline(false);
    DateAxis dateaxis = new DateAxis();
    RelativeDateFormat relativedateformat = new RelativeDateFormat();
    relativedateformat.setShowZeroDays(false);
    relativedateformat.setSecondFormatter(new DecimalFormat("00"));
    dateaxis.setDateFormatOverride(relativedateformat);
    xyplot.setRangeAxis(dateaxis);
    return jfreechart;
}

From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.charts.JFreeChartConn.java

/**
 * Updates the axis-related properties of a plot.
 * //from w  w  w  .  j  av a  2s .co m
 * @param aPlot
 *            Plot to be updated.
 * @param aAxes
 *            Axis-related visual settings to be applied.
 * @param aGrid
 *            Grid-related visual settings to be applied.
 */
private static void updateAxes(XYPlot aPlot, AxesSettings aAxes, GridSettings aGrid, Range aDomainDataRange,
        Range aRangeDataRange) {

    aPlot.setDomainAxis(createAxis(aAxes, true, aDomainDataRange));
    aPlot.setRangeAxis(createAxis(aAxes, false, aRangeDataRange));

    aPlot.setDomainGridlinesVisible(aGrid.getVerticalGridLines()); // set gridlines for X axis
    aPlot.setDomainGridlinePaint(aGrid.getGridLinesColor()); // set color of domain gridline

    aPlot.setRangeGridlinesVisible(aGrid.getHorizontalGridLines()); // set gridlines for Y axis
    aPlot.setRangeGridlinePaint(aGrid.getGridLinesColor()); // set color of range gridline
}

From source file:ec.ui.view.res.ResidualsView.java

private static JFreeChart buildResidualViewChart() {
    JFreeChart result = ChartFactory.createXYBarChart("Full residuals", "", false, "", Charts.emptyXYDataset(),
            PlotOrientation.VERTICAL, false, false, false);
    result.setPadding(TsCharts.CHART_PADDING);
    result.getTitle().setFont(TsCharts.CHART_TITLE_FONT);

    XYPlot plot = result.getXYPlot();

    DateAxis domainAxis = new DateAxis();
    domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    domainAxis.setLowerMargin(0);//from   ww  w .j  av a2  s .  c o m
    domainAxis.setUpperMargin(0);
    domainAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR);
    plot.setDomainAxis(domainAxis);

    NumberAxis rangeAxis = new NumberAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setTickLabelInsets(new RectangleInsets(10, 5, 10, 2));
    rangeAxis.setLowerMargin(0.02);
    rangeAxis.setUpperMargin(0.02);
    rangeAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR);
    plot.setRangeAxis(rangeAxis);

    XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setShadowVisible(false);
    renderer.setDrawBarOutline(true);
    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setAutoPopulateSeriesOutlinePaint(false);

    return result;
}

From source file:ec.util.chart.swing.JTimeSeriesRendererSupportDemo.java

private static JFreeChart createTsChart() {
    XYPlot plot = new XYPlot();

    plot.setAxisOffset(RectangleInsets.ZERO_INSETS);

    DateAxis domainAxis = new DateAxis();
    domainAxis.setTickLabelsVisible(false);
    domainAxis.setLowerMargin(0.02);//from   w w w. j  a  va2  s  .  c  o m
    domainAxis.setUpperMargin(0.02);
    plot.setDomainAxis(domainAxis);

    NumberAxis rangeAxis = new NumberAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setTickLabelsVisible(false);
    rangeAxis.setLowerMargin(0.02);
    rangeAxis.setUpperMargin(0.02);
    plot.setRangeAxis(rangeAxis);

    JFreeChart result = new JFreeChart("", null, plot, true);
    result.setPadding(new RectangleInsets(5, 5, 5, 5));
    result.getLegend().setFrame(BlockBorder.NONE);
    result.getLegend().setBackgroundPaint(null);

    return result;
}

From source file:ec.nbdemetra.chainlinking.outlineview.ChainLinkingChart.java

private void configureAxis(XYPlot plot) {
    NumberAxis xAxis = new NumberAxis();
    xAxis.setAutoRangeIncludesZero(false);
    plot.setRangeAxis(xAxis);

    QuarterDateFormat qdf = new QuarterDateFormat();
    DateAxis dateAxis = new DateAxis();
    dateAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    dateAxis.setDateFormatOverride(qdf);
    plot.setDomainAxis(dateAxis);// w w w  .  j a v  a2  s  . c  o m
}

From source file:net.sourceforge.processdash.ui.web.reports.snippets.EstErrorScatterChart.java

@Override
public JFreeChart createChart() {
    JFreeChart chart = super.createChart();

    // set minimum/maximum bounds on the two axes
    XYPlot xyPlot = chart.getXYPlot();
    double cutoff = getPercentParam("cut", 100, 200, 5000);
    xyPlot.setDomainAxis(truncAxis(xyPlot.getDomainAxis(), cutoff));
    xyPlot.setRangeAxis(truncAxis(xyPlot.getRangeAxis(), cutoff));
    xyPlot.setRenderer(new TruncatedItemRenderer(xyPlot.getRenderer()));

    // add a box illustrating the target range
    if (data.numRows() > 0) {
        double box = getPercentParam("pct", 0, 50, 100);
        xyPlot.addAnnotation(new XYBoxAnnotation(-box, -box, box, box));
        xyPlot.addAnnotation(new XYLineAnnotation(-box, 0, box, 0));
        xyPlot.addAnnotation(new XYLineAnnotation(0, -box, 0, box));
    }/*w ww .  j a v  a2 s  .c om*/

    return chart;
}

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

/**
 * Creates a new demo./*from   w  w w .j  a v a2s.com*/
 *
 * @param title  the frame title.
 */
public XYLogAxesDemo(final String title) {

    super(title);

    //Object[][][] data = new Object[3][50][2];
    final XYSeries s1 = new XYSeries("Series 1");
    final XYSeries s2 = new XYSeries("Series 2");
    final XYSeries s3 = new XYSeries("Series 3");

    //        for (int i = 1; i <= 50; i++) {
    //            s1.add(i, 1000 * Math.pow(i, -2));
    //            s2.add(i, 1000 * Math.pow(i, -3));
    //            s3.add(i, 1000 * Math.pow(i, -4));
    //        }

    for (int i = 1; i <= 50; i++) {
        s1.add(i, 10 * Math.exp(i / 5.0));
        s2.add(i, 20 * Math.exp(i / 5.0));
        s3.add(i, 30 * Math.exp(i / 5.0));
    }

    final XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(s1);
    dataset.addSeries(s2);
    dataset.addSeries(s3);

    final JFreeChart chart = ChartFactory.createXYLineChart("Log Axis Demo", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, false);

    final XYPlot plot = chart.getXYPlot();
    final NumberAxis domainAxis = new NumberAxis("x");
    final NumberAxis rangeAxis = new LogarithmicAxis("Log(y)");
    plot.setDomainAxis(domainAxis);
    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);

}

From source file:playground.dgrether.analysis.charts.DgMixedModeSwitcherOnlyDeltaScoreIncomeModeChoiceChart.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);/*w ww .jav  a2s  . com*/
    plot.setRangeAxis(yAxis);

    DgColorScheme colorScheme = new DgColorScheme();

    XYItemRenderer renderer1 = new XYLineAndShapeRenderer(false, true);
    renderer1.setSeriesPaint(0, colorScheme.COLOR3B);
    renderer1.setSeriesPaint(1, colorScheme.COLOR4B);
    plot.setDataset(0, this.inomeModeChoiceDs);
    plot.setRenderer(0, renderer1);

    XYItemRenderer renderer2;
    renderer2 = new XYLineAndShapeRenderer(true, true);
    plot.setDataset(1, this.avgDeltaScoreIncomeDs);
    for (int i = 2; i <= 3; i++) {
        renderer2.setSeriesStroke(i - 2, new BasicStroke(2.0f));
        renderer2.setSeriesOutlineStroke(i - 2, new BasicStroke(3.0f));
        renderer2.setSeriesPaint(i - 2, colorScheme.getColor(i + 1, "a"));
    }
    plot.setRenderer(1, renderer2);
    JFreeChart chart = new JFreeChart("", plot);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.getLegend().setItemFont(this.axisBuilder.getAxisFont());
    chart.setTextAntiAlias(true);
    return chart;
}

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

private void configureAxis(XYPlot plot) {
    NumberAxis xAxis = new NumberAxis();
    plot.setDomainAxis(xAxis);// ww  w. j a  v  a  2 s.c o  m
    NumberAxis yaxis = new NumberAxis();
    yaxis.setAutoRangeIncludesZero(false);
    plot.setRangeAxis(yaxis);
}