jzy3D从入门到弃坑_2
使用jzy3D0.9画2D散点图
代码
package momfo.metaheuristics.momfea;
import momfo.core.SolutionSet;
import org.jzy3d.chart.Chart;
import org.jzy3d.chart.ChartLauncher;
import org.jzy3d.colors.Color;
import org.jzy3d.global.Settings;
import org.jzy3d.maths.Coord3d;
import org.jzy3d.plot3d.primitives.Scatter;
import org.jzy3d.plot3d.rendering.canvas.Quality;
import org.jzy3d.chart.Chart;
import java.awt.*;
/*本示例根据*/
public class PlotTwoD_alpha {
public void plot(double[][] maxtrix, String title) {
int size = maxtrix.length;//size
int numobj = maxtrix[0].length;//2
float x;
float y;
float z;
float a;
Coord3d[] points = new Coord3d[size];
Color[] colors = new Color[size];
for (int i = 0; i < size; i++) {
x = 0;
y = (float) maxtrix[i][0];
z = (float) maxtrix[i][1];
points[i] = new Coord3d(x, y, z);
a = 0.25f;
colors[i] = new Color(x, y, z, a);
}
Scatter scatter = new Scatter(points, colors);
Chart chart = new Chart(Quality.Advanced, "awt");
chart.getScene().add(scatter);
Settings.getInstance().setHardwareAccelerated(true);
ChartLauncher.openChart(chart, new Rectangle(0, 0, 600, 600), title);
}
}