public String toStringMatrix() {
    StringBuffer        result;
    String[][]          cells;
    int                 i;
    int                 n;
    String              line;
    String              title;
    String              generated;

    result = new StringBuffer();
    cells  = toArray();

    // generation comment
    generated = "# generated by WEKA " + Version.VERSION + "\n";

    // data
    result.append("\n");
    result.append("##################\n");
    result.append("# file: plot.dat #\n");
    result.append("##################\n");
    result.append(generated);
    result.append("# contains the data for the plot\n");
    // key for x-axis
    result.append("\n");
    result.append("# key for the x-axis\n");
    for (i = 1; i < cells.length - 1; i++)
      result.append("# " + i + " - " + cells[i][0] + "\n");
    // the data itself
    result.append("\n");
    result.append("# data for the plot\n");
    for (i = 1; i < cells.length - 1; i++) {
      result.append(Integer.toString(i));
      for (n = 1; n < cells[i].length; n++) {
        if (isSignificance(n))
          continue;
        result.append(" ");
        result.append(Utils.quote(cells[i][n]));
      }
      result.append("\n");
    }
    result.append("#######\n");
    result.append("# end #\n");
    result.append("#######\n");

    // script
    result.append("\n");
    result.append("##################\n");
    result.append("# file: plot.scr #\n");
    result.append("##################\n");
    result.append(generated);
    result.append("# script to plot the data\n");
    result.append("\n");
    result.append("# display it in a window:\n");
    result.append("set terminal x11\n");
    result.append("set output\n");
    result.append("\n");
    result.append("# to display all data rows:\n");
    result.append("set xrange [0:" + ((cells.length - 2) + 1) + "]\n");
    result.append("\n");
    result.append("# axis labels, e.g.:\n");
    result.append("#set xlabel \"Datasets\"\n");
    result.append("#set ylabel \"Accuracy in %\"\n");
    result.append("\n");
    result.append("# the plot commands\n");
    n = 1;
    i = 0;
    while (i < cells[0].length - 1) {
      i++;

      if (isSignificance(i))
        continue;

      n++;
      
      // plot
      if (i == 1)
        line = "plot";
      else
        line = "replot";
      line += " \"plot.dat\"";

      // title
      title = "title \"" + cells[0][i] + "\"";
      
      // columns
      line += " using 1:" + n;
      if (getShowStdDev()) {
        n++;
        i++;
        // errorbars
        line += ":" + n;
      }
      
      // options
      line += " with";
      if (getShowStdDev())
        line += " yerrorbars";
      else
        line += " lines";
      line += " " + title;
      
      result.append(line + "\n");
    }
    result.append("\n");
    result.append("# generate ps:\n");
    result.append("#set terminal postscript\n");
    result.append("#set output \"plot.ps\"\n");
    result.append("#replot\n");
    result.append("\n");
    result.append("# generate png:\n");
    result.append("#set terminal png size 800,600\n");
    result.append("#set output \"plot.png\"\n");
    result.append("#replot\n");
    result.append("\n");
    result.append("# wait for user to hit <Return>\n");
    result.append("pause -1\n");
    result.append("#######\n");
    result.append("# end #\n");
    result.append("#######\n");
    
    return result.toString();
  }