我正在尝试更改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
答案 0 :(得分:0)
好吧,我认为您需要的是在散点图中使用setPointType而不是setLineType,因为没有Lines。它只有积分。
答案 1 :(得分:0)
正如mgilson在评论中所说:
use myStyle.setLineType(3);
(@ mgilson,如果你想得到答案的答案,那就自己写吧,给我留言,我会接受它而不是_