gpt4 book ai didi

java - 散点图不会改变颜色

转载 作者:行者123 更新时间:2023-12-01 05:14:59 26 4
gpt4 key购买 nike

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

最佳答案

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

关于java - 散点图不会改变颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11396616/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com