【问题标题】:Trisurf cannot plot into specified axisTrisurf 无法绘制到指定的轴
【发布时间】:2018-05-04 12:17:40
【问题描述】:

我想通过函数trisurf 绘制一个三角形曲面图,以指定轴为目标。但是,MATLAB 文档没有说明任何语法来做到这一点。当我打开函数时,我得到以下第一行:

function hh = trisurf(tri,varargin)
%TRISURF Triangular surface plot
%   TRISURF(TRI,X,Y,Z,C) displays the triangles defined in the M-by-3
%   face matrix TRI as a surface.  A row of TRI contains indexes into
%   the X,Y, and Z vertex vectors to define a single triangular face.
%   The color is defined by the vector C.
%
%   TRISURF(TRI,X,Y,Z) uses C = Z, so color is proportional to surface
%   height.
%
%   TRISURF(TR) displays the triangles in the triangulation TR. It uses
%   C = TR.X(:,3) to color the surface proportional to height.
%
%   H = TRISURF(...) returns a patch handle.
%
%   TRISURF(...,'param','value','param','value'...) allows additional
%   patch param/value pairs to be used when creating the patch object. 
%
%   Example:
%
%   [x,y] = meshgrid(1:15,1:15);
%   tri = delaunay(x,y);
%   z = peaks(15);
%   trisurf(tri,x,y,z)
%
%   % Alternatively
%   tr = triangulation(tri, x(:), y(:), z(:));
%   trisurf(tr)
%
%   See also PATCH, TRIMESH, DELAUNAY, triangulation, delaunayTriangulation.
%   Copyright 1984-2017 The MathWorks, Inc.
narginchk(1,inf);
ax = axescheck(varargin{:});
ax = newplot(ax);
start = 1;

函数输入不定义为varargin,例如在函数surf 中定义,因此无法将轴句柄指定为第一个输入变量。如果将轴句柄指定为第二个输入变量,则函数axescheck 会识别该句柄,但后来我得到一个错误,因为预期的第二个输入变量是一个向量。如果将轴句柄指定为第三个输入变量,则函数axescheck 根本无法识别该句柄。

我知道我可以先激活轴,然后调用trisurf,但我将它放在一个循环中,因此不建议这样做。有没有其他解决办法?

【问题讨论】:

    标签: matlab axis handle surface triangular


    【解决方案1】:

    如果您有您感兴趣的轴句柄,您可以做的是通过axes(youraxeshandle) 制作当前轴,并且只需使用trisurf 而无需任何特定输入。它应该被添加到当前轴,也就是你选择的那个。

    【讨论】:

    • 是的,这就是我的意思,首先激活轴,然后调用trisurf。但是,这在循环中效率不高。实际上,使用其他绘图功能可以将轴作为目标而不使其成为当前轴。我想知道trisurf 是否也有解决方案。
    • @Francesco 我认为这是你唯一的选择,很遗憾
    猜你喜欢
    • 2012-09-09
    • 2015-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多