我正在尝试使用gnuplot(在C ++中)制作3D表面图。这是我目前的代码。
function afterRender($viewFile) {
if (strlen($this->body) > 0) {
$this->_View->start('afterRenderBody');
echo $this->body;
$this->_View->end();
}
$afterRenderScripts = "";
if (strlen($this->script) > 0) {
$afterRenderScripts .= $this->functions;
$afterRenderScripts .= 'jQuery(document).ready(function ($) {';
if (!empty($this->formId)) {
foreach ($this->formId as $formId) {
$afterRenderScripts .= $this->_View->element('extended_form/validate/after_render_script', array('formId' => $formId, 'rules' => $this->rules));
}
}
$afterRenderScripts .= $this->script;
$afterRenderScripts .= '});';
}
$afterRenderScripts .= "jQuery(document).ready(function($) {
console.log('some extra scripts');
});";
//echo '<script type="text/javascript">' . $afterRenderScripts . "</script>";
$this->Html->scriptBlock($afterRenderScripts, array('block' => 'afterRenderScripts', 'inline' => false));
}
正如您所看到的,我已经尝试了许多命令(目前已注释)来实现目标。我似乎无法找到一个合适的命令组合或单个命令,它给我一个带有我寻求的表面的3D图形。
这是&#t; t.dat&#39; - 我试图绘制的数据:
//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";
有人知道需要做些什么来使这项工作?数据结构有问题吗?是否有一些我还没见过的命令?
答案 0 :(得分:1)
使用splot
,您只能在2D中绘制数据点(并连接它们)。要绘制曲面,您必须找到f(x,y)
函数以及splot
函数。或者您可以手动将一百或几千个曲面坐标插入到&#39; t2.dat&#39;和splot 't2.dat' w l
。