Java Code Examples for org.jfree.chart.annotations.XYTextAnnotation#setRotationAngle()

The following examples show how to use org.jfree.chart.annotations.XYTextAnnotation#setRotationAngle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CombinedDomainXYPlotTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a sample plot.
 *
 * @return A sample plot.
 */
private CombinedDomainXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis rangeAxis1 = new NumberAxis("Range 1");
    XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0,
            10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis rangeAxis2 = new NumberAxis("Range 2");
    rangeAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(
            new NumberAxis("Domain"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
 
Example 2
Source File: CombinedRangeXYPlotTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a sample plot.
 *
 * @return A sample plot.
 */
private CombinedRangeXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis xAxis1 = new NumberAxis("X1");
    XYPlot subplot1 = new XYPlot(data1, xAxis1, null, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation
            = new XYTextAnnotation("Hello!", 50.0, 10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis xAxis2 = new NumberAxis("X2");
    xAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, xAxis2, null, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    CombinedRangeXYPlot plot = new CombinedRangeXYPlot(new NumberAxis(
            "Range"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
 
Example 3
Source File: CombinedDomainXYPlotTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a sample plot.
 *
 * @return A sample plot.
 */
private CombinedDomainXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis rangeAxis1 = new NumberAxis("Range 1");
    XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0,
            10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis rangeAxis2 = new NumberAxis("Range 2");
    rangeAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(
            new NumberAxis("Domain"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
 
Example 4
Source File: CombinedRangeXYPlotTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a sample plot.
 *
 * @return A sample plot.
 */
private CombinedRangeXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis xAxis1 = new NumberAxis("X1");
    XYPlot subplot1 = new XYPlot(data1, xAxis1, null, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation
            = new XYTextAnnotation("Hello!", 50.0, 10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis xAxis2 = new NumberAxis("X2");
    xAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, xAxis2, null, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    CombinedRangeXYPlot plot = new CombinedRangeXYPlot(new NumberAxis(
            "Range"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
 
Example 5
Source File: CombinedDomainXYPlotTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a sample plot.
 *
 * @return A sample plot.
 */
private CombinedDomainXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis rangeAxis1 = new NumberAxis("Range 1");
    XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0,
            10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis rangeAxis2 = new NumberAxis("Range 2");
    rangeAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(
            new NumberAxis("Domain"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
 
Example 6
Source File: CombinedRangeXYPlotTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a sample plot.
 *
 * @return A sample plot.
 */
private CombinedRangeXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis xAxis1 = new NumberAxis("X1");
    XYPlot subplot1 = new XYPlot(data1, xAxis1, null, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation
            = new XYTextAnnotation("Hello!", 50.0, 10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis xAxis2 = new NumberAxis("X2");
    xAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, xAxis2, null, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    CombinedRangeXYPlot plot = new CombinedRangeXYPlot(new NumberAxis(
            "Range"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
 
Example 7
Source File: CombinedDomainXYPlotTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a sample plot.
 *
 * @return A sample plot.
 */
private CombinedDomainXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis rangeAxis1 = new NumberAxis("Range 1");
    XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0,
            10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis rangeAxis2 = new NumberAxis("Range 2");
    rangeAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(
            new NumberAxis("Domain"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
 
Example 8
Source File: CombinedRangeXYPlotTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a sample plot.
 *
 * @return A sample plot.
 */
private CombinedRangeXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis xAxis1 = new NumberAxis("X1");
    XYPlot subplot1 = new XYPlot(data1, xAxis1, null, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation
            = new XYTextAnnotation("Hello!", 50.0, 10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis xAxis2 = new NumberAxis("X2");
    xAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, xAxis2, null, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    CombinedRangeXYPlot plot = new CombinedRangeXYPlot(new NumberAxis(
            "Range"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
 
Example 9
Source File: CombinedDomainXYPlotTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a sample plot.
 *
 * @return A sample plot.
 */
private CombinedDomainXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis rangeAxis1 = new NumberAxis("Range 1");
    XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation
        = new XYTextAnnotation("Hello!", 50.0, 10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis rangeAxis2 = new NumberAxis("Range 2");
    rangeAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    CombinedDomainXYPlot plot
        = new CombinedDomainXYPlot(new NumberAxis("Domain"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
 
Example 10
Source File: CombinedRangeXYPlotTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a sample plot.
 *
 * @return A sample plot.
 */
private CombinedRangeXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis xAxis1 = new NumberAxis("X1");
    XYPlot subplot1 = new XYPlot(data1, xAxis1, null, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation
            = new XYTextAnnotation("Hello!", 50.0, 10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis xAxis2 = new NumberAxis("X2");
    xAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, xAxis2, null, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    CombinedRangeXYPlot plot = new CombinedRangeXYPlot(new NumberAxis(
            "Range"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
 
Example 11
Source File: CombinedDomainXYPlotTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a sample plot.
 * 
 * @return A sample plot.
 */
private CombinedDomainXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis rangeAxis1 = new NumberAxis("Range 1");
    XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    
    XYTextAnnotation annotation 
        = new XYTextAnnotation("Hello!", 50.0, 10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);
    
    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis rangeAxis2 = new NumberAxis("Range 2");
    rangeAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    CombinedDomainXYPlot plot 
        = new CombinedDomainXYPlot(new NumberAxis("Domain"));
    plot.setGap(10.0);
    
    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
 
Example 12
Source File: CombinedRangeXYPlotTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a sample plot.
 * 
 * @return A sample plot.
 */
private CombinedRangeXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis rangeAxis1 = new NumberAxis("Range 1");
    XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
     
    XYTextAnnotation annotation 
        = new XYTextAnnotation("Hello!", 50.0, 10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);
     
    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis rangeAxis2 = new NumberAxis("Range 2");
    rangeAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); 

    // parent plot...
    CombinedRangeXYPlot plot 
        = new CombinedRangeXYPlot(new NumberAxis("Range"));
    plot.setGap(10.0);
    
    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
 
Example 13
Source File: Scatter.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
public void addAnnotation( String text, double x ) {
    XYPlot plot = (XYPlot) getChart().getPlot();
    Color color = new Color(0, 0, 0, 100);
    Marker updateMarker = new ValueMarker(x, color, new BasicStroke(2f));
    plot.addDomainMarker(updateMarker);
    if (text != null) {
        XYTextAnnotation updateLabel = new XYTextAnnotation(text, x, 0);
        updateLabel.setRotationAnchor(TextAnchor.BASELINE_CENTER);
        updateLabel.setTextAnchor(TextAnchor.BASELINE_CENTER);
        updateLabel.setRotationAngle(-3.14 / 2);
        updateLabel.setPaint(Color.black);
        plot.addAnnotation(updateLabel);
    }
    setShapeLinesVisibility(plot);
}
 
Example 14
Source File: CombinedDomainXYPlotTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a sample plot.
 *
 * @return A sample plot.
 */
private CombinedDomainXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis rangeAxis1 = new NumberAxis("Range 1");
    XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0,
            10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis rangeAxis2 = new NumberAxis("Range 2");
    rangeAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(
            new NumberAxis("Domain"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
 
Example 15
Source File: CombinedRangeXYPlotTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a sample plot.
 *
 * @return A sample plot.
 */
private CombinedRangeXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis xAxis1 = new NumberAxis("X1");
    XYPlot subplot1 = new XYPlot(data1, xAxis1, null, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation
            = new XYTextAnnotation("Hello!", 50.0, 10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis xAxis2 = new NumberAxis("X2");
    xAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, xAxis2, null, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    CombinedRangeXYPlot plot = new CombinedRangeXYPlot(new NumberAxis(
            "Range"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}