dts.addNewDataTable("3x", x, y2);
jg.execute(plot0, jg.plot2d, TEMP_DIR);
}
public void prepPlot() {
plot1 = new Plot("plot1") {//No need to declare public/protected/private for these fields.
//String terminal, output, xrange, yrange, zrange;
//Quotation inside is necessary for xlabel and other fields cause you could add more config code
String xlabel = "'x axis' textcolor rgbcolor 'dark-red'", ylabel = "'y axis'", extra = "set key top left";
};
//DataTableSet 1 2d add data one by one
DataTableSet dts1 = plot1.addNewDataTableSet("DataTableSet 2d");//use null to avoid the output of figure title for this dataset.
DataTable dt1 = dts1.addNewDataTable("x", 2);
DataTable dt2 = dts1.addNewDataTable("2x", 2);
DataTable dt3 = dts1.addNewDataTable("3x", 2);
DataTable dt4 = dts1.addNewDataTable("4x", 2);
DataTable dt5 = dts1.addNewDataTable("5x", 2);
DataTable dt6 = dts1.addNewDataTable("6x", 2);
DataTable dt7 = dts1.addNewDataTable("7x", 2);
DataTable dt8 = dts1.addNewDataTable("8x", 2);
DataTable dt9 = dts1.addNewDataTable("9x", 2);
DataTable dt10 = dts1.addNewDataTable("10x", 2);
for (int i = 0; i < 5; i++) {
dt1.add(i, i);
dt2.add(i, 2 * i);
dt3.add(i, 3 * i);
dt4.add(i, 4 * i);
dt5.add(i, 5 * i);
dt6.add(i, 6 * i);
dt7.add(i, 7 * i);
dt8.add(i, 8 * i);
dt9.add(i, 9 * i);
dt10.add(i, 10 * i);
}
//DataTableSet 2 3d add data using prepared lists
DataTableSet dts2 = plot1.addNewDataTableSet("DataTableSet 3d");
List x = new ArrayList(), y = new ArrayList(), z1 = new ArrayList(), z2 = new ArrayList();
for (double i = -2; i <= 2; i += 0.5) {
for (double j = -2; j <= 2; j += 0.5) {
x.add(i);
y.add(j);
z1.add(i * i + j * j);
z2.add(4 + i * i + j * j);
}
}
dts2.addNewDataTable("x^2+y^2", x, y, z1);
dts2.addNewDataTable("4+x^2+y^2", x, y, z2);
DataTableSet dts3 = dts1;
plot1.add(dts3);
plot2 = new Plot("plot2") {
String zlabel = "'z axis'";
};
plot2.add(dts2);
}