Example usage for org.jfree.chart.axis NumberAxis setLowerMargin

List of usage examples for org.jfree.chart.axis NumberAxis setLowerMargin

Introduction

In this page you can find the example usage for org.jfree.chart.axis NumberAxis setLowerMargin.

Prototype

public void setLowerMargin(double margin) 

Source Link

Document

Sets the lower margin for the axis (as a percentage of the axis range) and sends an AxisChangeEvent to all registered listeners.

Usage

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

private static JFreeChart createChart() {
    OHLCDataset ohlcdataset = createPriceDataset();
    String s = "Sun Microsystems (SUNW)";
    JFreeChart jfreechart = ChartFactory.createHighLowChart(s, "Date", "Price", ohlcdataset, true);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setLowerMargin(0.01D);/*from  w ww .j  a v a  2  s . c om*/
    dateaxis.setUpperMargin(0.01D);
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setLowerMargin(0.59999999999999998D);
    numberaxis.setAutoRangeIncludesZero(false);
    XYItemRenderer xyitemrenderer = xyplot.getRenderer();
    xyitemrenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: ({1}, {2})",
            new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));
    NumberAxis numberaxis1 = new NumberAxis("Volume");
    numberaxis1.setUpperMargin(1.0D);
    xyplot.setRangeAxis(1, numberaxis1);
    xyplot.setDataset(1, createVolumeDataset());
    xyplot.setRangeAxis(1, numberaxis1);
    xyplot.mapDatasetToRangeAxis(1, 1);
    XYBarRenderer xybarrenderer = new XYBarRenderer();
    xybarrenderer.setDrawBarOutline(false);
    xybarrenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: ({1}, {2})",
            new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0,000.00")));
    xyplot.setRenderer(1, xybarrenderer);
    ChartUtilities.applyCurrentTheme(jfreechart);
    xybarrenderer.setShadowVisible(false);
    xybarrenderer.setBarPainter(new StandardXYBarPainter());
    return jfreechart;
}

From source file:org.csml.tommo.sugar.heatmap.MappingQualityMatrixChart.java

public static MappingQualityMatrixChart createNiceChart(MappingQualityMatrixDataset dataset,
        PaintScale paintScale) {//  ww  w  .j  av  a2s .  co m

    Rectangle range = dataset.getMappingQualityMatrix().getRange();
    String xLabel = "X from " + range.x + " to " + (range.x + range.width);
    String yLabel = "Y from " + range.y + " to " + (range.y + range.height);

    NumberAxis xAxis = new NumberAxis(xLabel);
    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    xAxis.setTickLabelsVisible(true);
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);

    NumberAxis yAxis = new NumberAxis(yLabel);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    yAxis.setTickLabelsVisible(true);
    yAxis.setLowerMargin(0.0);
    yAxis.setUpperMargin(0.0);

    MappingQualityMatrixChart chart = createChart(dataset, xAxis, yAxis, paintScale);

    // draw paint scale legend
    chart.setPaintScaleLegend(paintScale);

    return chart;
}

From source file:org.csml.tommo.sugar.heatmap.MeanQualityMatrixChart.java

public static MeanQualityMatrixChart createNiceChart(MeanQualityMatrixDataset dataset, PaintScale paintScale) {

    Rectangle range = dataset.getMeanQualityMatrix().getRange();
    String xLabel = "X from " + range.x + " to " + (range.x + range.width);
    String yLabel = "Y from " + range.y + " to " + (range.y + range.height);

    NumberAxis xAxis = new NumberAxis(xLabel);
    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    xAxis.setTickLabelsVisible(true);//from   w w w. j  av a  2 s.c o  m
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);

    NumberAxis yAxis = new NumberAxis(yLabel);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    yAxis.setTickLabelsVisible(true);
    yAxis.setLowerMargin(0.0);
    yAxis.setUpperMargin(0.0);

    MeanQualityMatrixChart chart = createChart(dataset, xAxis, yAxis, paintScale);

    // draw paint scale legend
    chart.setPaintScaleLegend(paintScale);

    return chart;
}

From source file:org.spf4j.perf.impl.chart.Charts.java

public static JFreeChart createHeatJFreeChart(final String[] dsNames, final double[][] values,
        final long startTimeMillis, final long stepMillis, final String uom, final String chartName) {
    final QuantizedXYZDatasetImpl dataSet = new QuantizedXYZDatasetImpl(dsNames, values, startTimeMillis,
            stepMillis);/*w ww  .ja v a 2  s.  c o m*/
    NumberAxis xAxis = new NumberAxis("Time");
    xAxis.setStandardTickUnits(dataSet.createXTickUnits());
    xAxis.setLowerMargin(0);
    xAxis.setUpperMargin(0);
    xAxis.setVerticalTickLabels(true);
    NumberAxis yAxis = new NumberAxis(uom);
    yAxis.setStandardTickUnits(dataSet.createYTickUnits());
    yAxis.setLowerMargin(0);
    yAxis.setUpperMargin(0);
    XYBlockRenderer renderer = new XYBlockRenderer();
    PaintScale scale;
    if (dataSet.getMinValue() >= dataSet.getMaxValue()) {
        if (dataSet.getMinValue() == Double.POSITIVE_INFINITY) {
            scale = new InverseGrayScale(0, 1);
        } else {
            scale = new InverseGrayScale(dataSet.getMinValue(), dataSet.getMaxValue() + 1);
        }
    } else {
        scale = new InverseGrayScale(dataSet.getMinValue(), dataSet.getMaxValue());
    }
    renderer.setPaintScale(scale);
    renderer.setBlockWidth(1);
    renderer.setBlockHeight(1);
    XYPlot plot = new XYPlot(dataSet, xAxis, yAxis, renderer);
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    plot.setRangeMinorGridlinesVisible(false);
    JFreeChart chart = new JFreeChart(chartName, plot);
    PaintScaleLegend legend = new PaintScaleLegend(scale, new NumberAxis("Count"));
    legend.setMargin(0, 5, 0, 5);
    chart.addSubtitle(legend);
    chart.removeLegend();
    chart.setBackgroundPaint(Color.white);
    return chart;
}

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();/*from  www .j  av a 2s  .  c o m*/

    DateAxis domainAxis = new DateAxis();
    domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    domainAxis.setLowerMargin(0);
    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:org.jfree.chart.demo.CandlestickChartDemo1.java

private static JFreeChart createChart(OHLCDataset ohlcdataset) {
    JFreeChart jfreechart = ChartFactory.createCandlestickChart("Candlestick Demo 1", "Time", "Value",
            ohlcdataset, true);//from   w  ww.  j a v  a2s  .  c  o m
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setAutoRangeIncludesZero(false);
    numberaxis.setUpperMargin(0.0D);
    numberaxis.setLowerMargin(0.0D);
    return jfreechart;
}

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

private static JFreeChart createChart() {
    XYDataset xydataset = createPriceDataset();
    String s = "Eurodollar Futures Contract (MAR03)";
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(s, "Date", "Price", xydataset, true, true,
            false);//from w  w  w.j a  v a 2  s  . c  o m
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setLowerMargin(0.40000000000000002D);
    DecimalFormat decimalformat = new DecimalFormat("00.00");
    numberaxis.setNumberFormatOverride(decimalformat);
    XYItemRenderer xyitemrenderer = xyplot.getRenderer();
    xyitemrenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: ({1}, {2})",
            new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));
    NumberAxis numberaxis1 = new NumberAxis("Volume");
    numberaxis1.setUpperMargin(1.0D);
    xyplot.setRangeAxis(1, numberaxis1);
    xyplot.setDataset(1, createVolumeDataset());
    xyplot.setRangeAxis(1, numberaxis1);
    xyplot.mapDatasetToRangeAxis(1, 1);
    XYBarRenderer xybarrenderer = new XYBarRenderer(0.20000000000000001D);
    xybarrenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: ({1}, {2})",
            new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0,000.00")));
    xyplot.setRenderer(1, xybarrenderer);
    return jfreechart;
}

From source file:org.gumtree.vis.awt.PlotFactory.java

private static NumberAxis createYAxis(IXYZDataset dataset) {
    String title = "";
    String yTitle = dataset.getYTitle();
    if (yTitle != null) {
        title += yTitle;/*from ww w.java2 s . c om*/
    }
    String yUnits = dataset.getYUnits();
    if (yUnits != null) {
        title += " (" + yUnits + ")";
    }
    if (title.trim().length() == 0) {
        title = null;
    }
    NumberAxis yAxis = new NumberAxis(title);
    yAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    yAxis.setLowerMargin(0.0);
    yAxis.setUpperMargin(0.0);
    yAxis.setAutoRangeIncludesZero(false);
    return yAxis;
}

From source file:org.gumtree.vis.awt.PlotFactory.java

private static NumberAxis createXAxis(IXYZDataset dataset) {
    String title = "";
    String xTitle = dataset.getXTitle();
    if (xTitle != null) {
        title += xTitle;/*from w ww .j  a  v a2  s  . co m*/
    }
    String xUnits = dataset.getXUnits();
    if (xUnits != null) {
        title += " (" + xUnits + ")";
    }
    if (title.trim().length() == 0) {
        title = null;
    }
    NumberAxis xAxis = new NumberAxis(title);
    xAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);
    xAxis.setAutoRangeIncludesZero(false);
    return xAxis;
}

From source file:org.hxzon.demo.jfreechart.OtherDatasetDemo.java

private static JFreeChart createStackedXYAreaChart(TableXYDataset dataset) {
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);//from   w ww .ja va  2  s .c  o  m
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    XYToolTipGenerator toolTipGenerator = null;
    if (tooltips) {
        toolTipGenerator = new StandardXYToolTipGenerator();
    }

    XYURLGenerator urlGenerator = null;
    if (urls) {
        urlGenerator = new StandardXYURLGenerator();
    }
    StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(toolTipGenerator, urlGenerator);
    renderer.setOutline(true);
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(orientation);

    plot.setRangeAxis(yAxis); // forces recalculation of the axis range

    JFreeChart chart = new JFreeChart("StackedXYArea Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    chart.setBackgroundPaint(Color.white);

    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);

    return chart;
}