jzy3D从入门到弃坑_2
使用jzy3D0.9画2D散点图
觉得有用的话,欢迎一起讨论相互学习~
![](https://img2020.cnblogs.com/blog/949241/202004/949241-20200404123341456-2091227860.png)
![我的微博](https://img2020.cnblogs.com/blog/949241/202004/949241-20200404125636151-1411970006.png)
![我的github](https://img2020.cnblogs.com/blog/949241/202004/949241-20200404125603323-1670542535.jpg)
![我的B站](https://img2020.cnblogs.com/blog/949241/202004/949241-20200404142715197-1867301511.jpg)
代码
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);
}
}