Back to Documentation/Tutorial
jmathplot :
groovy :
sample for factors a and b, and output y
println "(" + factors.a + "," + factors.b + ")"
factors.each{
println "f(" + it.a + "," + it.b + ") = "
}
output.each{
println it.y
}
import javax.swing.*;
import org.math.plot.*;
// define your data
double[] x = new double[factors.size()]
double[] y = new double[factors.size()]
double[] z = new double[factors.size()]
for (int i = 0; i < factors.size(); i++) {
x[i] = (double) factors[i].a
y[i] = (double) factors[i].b
z[i] = (double) output[i].y
}
// create your PlotPanel (you can use it as a JPanel)
Plot3DPanel plot = new Plot3DPanel();
// define the legend position
//plot.addLegend("SOUTH");
// add a line plot to the PlotPanel
plot.addScatterPlot("my plot", x, y, z);
// put the PlotPanel in a JFrame like a JPanel
JFrame frame = new JFrame("a plot panel");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
frame.setSize(600, 600);
frame.setContentPane(plot);
frame.setVisible(true);
//Make a Pause
Thread.sleep(300000)





