Example usage for org.jfree.chart.plot CombinedDomainXYPlot setDomainAxis

List of usage examples for org.jfree.chart.plot CombinedDomainXYPlot setDomainAxis

Introduction

In this page you can find the example usage for org.jfree.chart.plot CombinedDomainXYPlot setDomainAxis.

Prototype

public void setDomainAxis(ValueAxis axis) 

Source Link

Document

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

Usage

From source file:org.fhcrc.cpl.viewer.gui.SpectrumChartFactory.java

public static ChartPanel CreateChartPanel(java.util.List datasets, Color[] colors) {
    if (datasets.size() == 1)
        return CreateChartPanel((XYSeriesCollection) datasets.get(0), colors);

    CombinedDomainXYPlot combined = new CombinedDomainXYPlot();
    for (Iterator it = datasets.iterator(); it.hasNext();) {
        XYSeriesCollection series = (XYSeriesCollection) it.next();
        XYPlot xy = createXYPlot(series, colors);
        combined.add(xy);// w  w w. j a  v  a 2  s  .c o  m
    }
    NumberAxis axisDomain = new NumberAxis();
    axisDomain.setAutoRangeIncludesZero(false);
    //      axisDomain.setRange(400.0, 1600.0);
    combined.setDomainAxis(axisDomain);

    JFreeChart chart = new JFreeChart(combined);
    ChartPanel chartPanel = new SpectrumChartPanel(chart);
    chartPanel.setDisplayToolTips(true);
    chartPanel.setMouseZoomable(true);
    // Remove the autogenerated subtitle
    if (chart.getSubtitleCount() == 1)
        chart.removeSubtitle(chart.getSubtitle(chart.getSubtitleCount() - 1));
    return chartPanel;
}

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

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

    plot.setAxisOffset(RectangleInsets.ZERO_INSETS);

    DateAxis domainAxis = new DateAxis();
    domainAxis.setTickLabelInsets(new RectangleInsets(2, 5, 2, 5));
    domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    domainAxis.setLowerMargin(0.02);//from w w w . j  a va  2s .  co  m
    domainAxis.setUpperMargin(0.02);
    plot.setDomainAxis(domainAxis);

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

    return result;
}

From source file:jboost.visualization.HistogramFrame.java

private JFreeChart createHistogramChart() {

    XYBarRenderer renderer1 = new XYBarRenderer();
    renderer1.setSeriesPaint(0, Color.cyan);
    renderer1.setSeriesPaint(1, Color.pink);

    XYPlot histPlot = new XYPlot(histogramDataset, null, new NumberAxis("count"), renderer1);

    XYBarRenderer renderer2 = new XYBarRenderer();
    renderer2.setSeriesPaint(0, Color.green);
    renderer2.setSeriesPaint(1, Color.orange);
    renderer2.setUseYInterval(true);//from   w ww .  j a va 2  s  .  com

    // weight and potential
    if (infoParser.isRobustBoost || infoParser.isAdaBoost || infoParser.isLogLossBoost) {
        StandardXYItemRenderer renderer3 = new StandardXYItemRenderer();
        renderer3.setSeriesPaint(0, Color.blue);
        renderer3.setSeriesPaint(1, Color.red);
        renderer3.setBaseStroke(new BasicStroke(2));

        StandardXYItemRenderer renderer4 = new StandardXYItemRenderer();
        renderer4.setSeriesPaint(0, Color.blue);
        renderer4.setSeriesPaint(1, Color.red);
        renderer4.setBaseStroke(
                new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 2, new float[] { 2 }, 0));

        histPlot.setDataset(1, weightDataset);
        histPlot.setRenderer(1, renderer3);

        histPlot.setDataset(2, potentialDataset);
        histPlot.setRenderer(2, renderer4);

        histPlot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    }

    XYPlot fluctPlot = new XYPlot(fluctDataset, null, new NumberAxis("bin"), renderer2);

    double initialLocation = (upper_limit + lower_limit) / 2.0;
    histMarker = new IntervalMarker(initialLocation, initialLocation);
    histPlot.addDomainMarker(histMarker, Layer.BACKGROUND);
    fluctPlot.addDomainMarker(histMarker, Layer.BACKGROUND);

    // plot.setBackgroundPaint(Color.lightGray);
    // plot.setDomainGridlinePaint(Color.white);
    // plot.setRangeGridlinePaint(Color.white);

    CombinedDomainXYPlot combinedPlot = new CombinedDomainXYPlot(new NumberAxis("score"));
    combinedPlot.setGap(10.0);

    // add the subplots...
    ValueAxis axis = new NumberAxis();
    axis.setRange(rawData.getMinRange(iter), rawData.getMaxRange(iter));
    combinedPlot.add(histPlot, 3);
    combinedPlot.add(fluctPlot, 1);
    combinedPlot.setOrientation(PlotOrientation.VERTICAL);
    combinedPlot.setDomainAxis(axis);

    JFreeChart chart = new JFreeChart("Histogram", JFreeChart.DEFAULT_TITLE_FONT, combinedPlot, false // legend
    );

    return chart;
}