我正在尝试更改 3D 散点图上点的颜色。点变为黑色,而不是我想要的颜色,键上的点变为正确的颜色。有谁知道为什么会这样?
import com.panayotis.gnuplot.JavaPlot;
import com.panayotis.gnuplot.plot.*;
import com.panayotis.gnuplot.style.NamedPlotColor;
import com.panayotis.gnuplot.style.PlotStyle;
import com.panayotis.gnuplot.style.Style;
public class ScatterPlot4D {
public static void main(String[] args) {
int rows = 100;
int D = 4;
double [][] dataSet = new double [rows][D];
for(int x = 0;x < rows; x++){
for(int y = 0;y < D; y++){
dataSet[x][y]=Math.random();
}
}
JavaPlot p = new JavaPlot("C:\\Program Files\\gnuplot\\bin\\pgnuplot.exe");
p.newGraph3D();
PlotStyle myStyle = new PlotStyle();
myStyle.setStyle(Style.POINTS);
myStyle.setLineType(NamedPlotColor.BLUE);
DataSetPlot myPlot = new DataSetPlot(dataSet);
myPlot.setPlotStyle(myStyle);
p.addPlot(myPlot);
p.splot();
}
}
奇怪的是这在绘制函数时有效。
import com.panayotis.gnuplot.GNUPlot;
import com.panayotis.gnuplot.plot.*;
import com.panayotis.gnuplot.style.NamedPlotColor;
import com.panayotis.gnuplot.style.PlotStyle;
import com.panayotis.gnuplot.style.Style;
public class test3D {
public static void main(String[] args) {
GNUPlot p = new GNUPlot("C:\\Program Files\\gnuplot\\bin\\pgnuplot.exe");
p.newGraph3D();
PlotStyle myStyle = new PlotStyle();
myStyle.setStyle(Style.IMPULSES);
myStyle.setLineType(NamedPlotColor.BLUE);
FunctionPlot myPlot = new FunctionPlot("tan(x)");
myPlot.setTitle("3D Plot");
myPlot.setPlotStyle(myStyle);
p.addPlot(myPlot);
p.splot();
}
}
正在向 gnuplot 发送命令:
gnuplot> set multiplot layout 1,2 rowsfirst downwards
multiplot> _gnuplot_error = 1
multiplot> splot '-' title 'Datafile 1' with points linetype rgb 'blue' ;_gnuplot_error = 0X
input data ('e' ends) > random data is here, not included for brevity
multiplot> if (_gnuplot_error == 1) print '_ERROR_'
multiplot> unset multiplot