我正在尝试使用gnuplot(在C ++中)制作3D浮雕图。这是我目前拥有的代码。
//gp << "set dgrid3d\n";
//gp << "set samples 10,10\n";
//gp << "set isosamples 10,10\n";
//gp << "set contour\n";
//gp << "set hidden3d\n";
//gp << "set surface\n";
//gp << "set pm3d\n";
gp << "splot 't.dat' u 1:4:5 w linespoints pointtype 7 pointsize 1.5, \
't.dat' u 2:4:5 w linespoints pointtype 9 pointsize 1.5, \
't.dat' u 3:4:5 w linespoints pointtype 4 pointsize 1.5\n";
如您所见,我已经尝试了许多命令(当前已注释)以实现该目标。我似乎找不到合适的命令组合或单个命令,该命令无法为我提供具有我所寻找的表面的3D图形。
这是't.dat'-我正在尝试绘制的数据:
#timeTaken1 timeTaken2 timeTaken3 D E
1.2342423 1.33 2.442 1 0
1.234234 1.55 2.236 1 20
2.56465 1.56 3.39 1 40
2.464 1.234 3.224 1 60
2.2747 1.768 3.552 1 80
2.34774 1.876 3.574 1 100
3.34747 2.94 4.795 2 0
3.34747 2.66 5.776 2 20
3.3747 3.234 5.666 2 40
3.787 3.66 6.503 2 60
3.456 3.88 6.37 2 80
4.345 3.345 5.853 2 100
有人知道要做什么才能完成这项工作吗?数据结构有问题吗?有没有我没看到的命令?
最佳答案
使用splot
,您只能在2D模式下绘制数据点(并连接它们)。要绘制表面,您必须找到一个f(x,y)
函数,同时还要找到splot
。或者,您可以将一百或数千个表面坐标手动插值到't2.dat'和splot 't2.dat' w l
中。
关于c++ - 使用gnuplot制作3D表面图,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43208117/