/**
   * Vertically combined sample1 and sample2 and display it.
   *
   * @param frameTitle the frame title.
   * @param data1 the dataset 1.
   * @param data2 the dataset 2.
   */
  private static void displayXYSymbolicCombinedVertically(
      String frameTitle, XYDataset data1, XYDataset data2) {

    String title = "Pollutant Vertically Combined";
    String xAxisLabel = "Contamination and Type";
    String yAxisLabel = "Pollutant";

    // combine the x symbolic values of the two data sets
    String[] combinedXSymbolicValues =
        SampleXYSymbolicDataset.combineXSymbolicDataset((XisSymbolic) data1, (XisSymbolic) data2);

    // make master dataset...
    CombinedDataset data = new CombinedDataset();
    data.add(data1);
    data.add(data2);

    // decompose data...
    XYDataset series0 = new SubSeriesDataset(data, 0);
    XYDataset series1 = new SubSeriesDataset(data, 1);

    // common horizontal and vertical axes
    SymbolicAxis hsymbolicAxis = new SymbolicAxis(xAxisLabel, combinedXSymbolicValues);

    SymbolicAxis vsymbolicAxis0 =
        new SymbolicAxis(yAxisLabel, ((YisSymbolic) data1).getYSymbolicValues());

    SymbolicAxis vsymbolicAxis1 =
        new SymbolicAxis(yAxisLabel, ((YisSymbolic) data2).getYSymbolicValues());

    // create the main plot...
    CombinedDomainXYPlot mainPlot = new CombinedDomainXYPlot(hsymbolicAxis);

    // add the sub-plots...
    XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null);
    XYPlot subplot0 = new XYPlot(series0, null, vsymbolicAxis0, renderer);
    XYPlot subplot1 = new XYPlot(series1, null, vsymbolicAxis1, renderer);

    mainPlot.add(subplot0, 1);
    mainPlot.add(subplot1, 1);

    // make the chart...
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, mainPlot, true);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));

    // and present it in a frame...
    JFrame frame = new ChartFrame(frameTitle, chart);
    frame.pack();
    RefineryUtilities.positionFrameRandomly(frame);
    frame.show();
  }
  /**
   * Displays an overlaid XYPlot with X and Y symbolic data.
   *
   * @param frameTitle the frame title.
   * @param data1 the dataset 1.
   * @param data2 the dataset 2.
   */
  private static void displayXYSymbolicOverlaid(
      String frameTitle, XYDataset data1, XYDataset data2) {

    String title = "Pollutant Overlaid";
    String xAxisLabel = "Contamination and Type";
    String yAxisLabel = "Pollutant";

    // combine the x symbolic values of the two data sets
    String[] combinedXSymbolicValues =
        SampleXYSymbolicDataset.combineXSymbolicDataset((XisSymbolic) data1, (XisSymbolic) data2);

    // combine the y symbolic values of the two data sets
    String[] combinedYSymbolicValues =
        SampleXYSymbolicDataset.combineYSymbolicDataset((YisSymbolic) data1, (YisSymbolic) data2);

    // make master dataset...
    CombinedDataset data = new CombinedDataset();
    data.add(data1);
    data.add(data2);

    // decompose data...
    XYDataset series0 = new SubSeriesDataset(data, 0);
    XYDataset series1 = new SubSeriesDataset(data, 1);

    // create overlaid plot...
    SymbolicAxis hsymbolicAxis = new SymbolicAxis(xAxisLabel, combinedXSymbolicValues);
    SymbolicAxis vsymbolicAxis = new SymbolicAxis(yAxisLabel, combinedYSymbolicValues);

    XYItemRenderer renderer1 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null);
    XYPlot plot = new XYPlot(series0, hsymbolicAxis, vsymbolicAxis, renderer1);

    XYItemRenderer renderer2 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null);
    plot.setSecondaryDataset(0, series1);
    plot.setSecondaryRenderer(0, renderer2);

    // make the chart...
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));

    // and present it in a frame...
    JFrame frame = new ChartFrame(frameTitle, chart);
    frame.pack();
    RefineryUtilities.positionFrameRandomly(frame);
    frame.show();
  }