1

我正在尝试更改 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
4

2 回答 2

0

好吧,我认为您需要的是在散点图中使用 setPointType 而不是 setLineType,因为它没有线条。它只有积分。

于 2012-07-10T01:38:57.593 回答
0

正如 mgilson 在评论中所说:

 use myStyle.setLineType(3);

(@mgilson,如果您想获得答案,请自己写,给我发消息,我会接受它_

于 2013-06-24T18:35:52.037 回答