【问题标题】:plot a 3 axis graph as a mesh将 3 轴图绘制为网格
【发布时间】:2008-11-05 23:34:28
【问题描述】:

我以前看过数据的 3d 曲面图,但我不知道我可以使用什么软件来制作它。

我有 3 系列数据(X、Y、Z),基本上我希望表格上的每一行都是 3d 空间中的一个点,全部连接为一个网格。数据目前是 csv,但我可以更改格式,因为它是我自己生成的数据。

谁能帮忙

【问题讨论】:

  • 我希望它适用于 X、Y、Z 的任何值。当我研究使用 matlab 时,它想要 X 和 Y 的系列(每次差异都相同)和 z作为 x 和 y 的函数
  • 您是否已经知道点的连通性,还是希望软件从一组无序的点中推断出网格结构?

标签: math matlab 3d graph plot


【解决方案1】:

如果您的 x 和 y 点在拓扑上位于网格上,则可以使用 MESH。它们不需要均匀的间距;它们只需要组织起来,以便 x(r:r+1,c:c+1) 和 y(r:r+1,c:c+1) 在网格上为每一行 r 和每一列定义一个四边形c.

如果您的数据不在网格上,但您知道面应该是什么,请查看 PATCH 函数。

如果你只有积分,对表面一无所知,你需要先解决surface reconstruction问题。我用过椰子;那里也有其他不错的包裹。一旦你有了重建的表面,你就可以使用 PATCH 来显示它。

【讨论】:

  • +1 用于在 OP 想要生成表面而不是点云时突出显示正确的问题。
【解决方案2】:

您是否考虑过使用vtk?如果你有 Matlab,那么你应该能够使用 plot3dsurfmeshgridgriddata 来生成 3D 表面Mr. Fooz 建议的地块或 补丁

【讨论】:

  • 这对我来说看起来太复杂了,我可以访问 matlab 但我没有使用它的经验。如果我稍微玩一下,nlucaroni 的脚本似乎可以满足我的一切需求。谢谢:D
  • 授予的 vtk 可能对您的需要来说太强大了。 Matlab/Scilab/Octave 都相当简单。
【解决方案3】:

gnuplot 或scilab

以下是我不久前为 SciLab 编写的脚本。它读取由制表符分隔的三列。您可以轻松更改此设置以满足您的需求,非常不言自明。这是reading/writing in scilab 的快速指南,我在下面引用的是here

function plot_from_file(datafile)
//
// Make a simple x-y-z plot based on values read from a datafile.
// We assume that the datafile has three columns of floating-point
// values seperated by tabs.

  // set verbose = 1 to see lots of diagnostics
  verbose = 1;

  // open the datafile (quit if we can't)
  fid = mopen(datafile, 'r');
  if (fid == -1) 
    error('cannot open datafile');
  end

  // loop over all lines in the file, reading them one at a time
  num_lines = 0;
  while (true)

    // try to read the line ...
    [num_read, val(1), val(2), val(3)] = mfscanf(fid, "%f\t%f\t%f");
    if (num_read <= 0)
      break
    end
    if (verbose > 0)
      fprintf(1, 'num_lines %3d  num_read %4d \n', num_lines, num_read);
    end
    if (num_read ~= 3) 
      error('didn''t read three points');
    end

    // okay, that line contained valid data.  Store in arrays
    num_lines = num_lines + 1;
    x_array(num_lines) = val(1);
    y_array(num_lines) = val(2);
    z_array(num_lines) = val(3);
  end

  // now, make the plot
  plot3d2(x_array, y_array, z_array);
  // close the datafile
  mclose(fid);

endfunction

【讨论】:

  • 等一下……我回家后会检查脚本。为什么我没有在任何地方使用 done_yet??
  • 这看起来对我有用,但你说它不完整,看起来它会是一个无限循环。我用scilab容易吗?
  • 似乎这只会产生一堆点。听起来你想要一个表面。
  • 好的,不。休息一下。但过去它不是中断线,而是将 done_yet 设置为 0。对 Azim:然后他必须插入数据,这与他所要求的不同。
  • 致@nlucaroni 我想我关注的是问题的“作为网格连接”部分。然后我同意 OP 需要按照 Fooz 先生指出的那样格式化数据。
猜你喜欢
  • 2018-09-23
  • 2020-07-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-16
  • 2016-03-13
  • 1970-01-01
相关资源
最近更新 更多