I want to write software for 3D charts in java.I found something like gnuplot and JavaGnuplotHybrid and this example:
JGnuplot jg = new JGnuplot();
Plot plot0 = new Plot("2d plot") {
String xlabel = "'x'", ylabel = "'y'";
};
double[] x = { 1, 2, 3, 4, 5 }, y1 = { 2, 4, 6, 8, 10 }, y2 = { 3, 6, 9, 12, 15 };
DataTableSet dts = plot0.addNewDataTableSet("Simple plot");
dts.addNewDataTable("2x", x, y1);
dts.addNewDataTable("3x", x, y2);
jg.execute(plot0, jg.plot2d);
The code works and shows chart. I do not know how to begin 3d graph if someone could write such a beautiful simple example of a single point on the 3D graph ?
Here is the code for an example 3d graph:
public void plot3d() {
JGnuplot jg = new JGnuplot();
Plot plot = new Plot("") {
{
xlabel = "x";
ylabel = "y";
zlabel = "z";
}
};
double[] x = { 1, 2, 3, 4, 5 }, y = { 2, 4, 6, 8, 10 }, z = { 3, 6, 9, 12, 15 }, z2 = { 2, 8, 18, 32, 50 };
DataTableSet dts = plot.addNewDataTableSet("3D Plot");
dts.addNewDataTable("z=x+y", x, y, z);
dts.addNewDataTable("z=x*y", x, y, z2);
jg.execute(plot, jg.plot3d);
}
It produces the following figure:
Here are more examples: 2D Plot, Bar Plot, 3D Plot, Density Plot, Image Plot...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.