散点图不会改变颜色 [英] Scatter Plot will not change color
本文介绍了散点图不会改变颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试更改3D散点图上点的颜色.这些点变为黑色,而不是我想要的颜色,并且按键上的点变为正确的颜色.有人知道为什么会这样吗?
I'm trying to change the color of the points on my 3D Scatter Plot. The points change to black, not the color I want and the point on the key changes to the correct color. Does anyone know why this occurs?
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();
}
}
在绘制函数图形时这很奇怪.
What's weird is this works when graphing a function.
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 is being sent the commands:
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
推荐答案
正如mgilson在评论中所说:
As mgilson said in the comments:
use myStyle.setLineType(3);
(@ mgilson,如果您想给答案一个信用,那就自己写一个,给我发消息,我会接受它的.
(@mgilson, if you want credit for the answer, just write it yourself, message me and I'll accept it instead_
这篇关于散点图不会改变颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文