Trisurf cannot plot into specified axis
18 ビュー (過去 30 日間)
古いコメントを表示
I would like to make a triangular surface plot throught the function trisurf, targeting a specified axis. However, MATLAB documentation does not indicate any syntax to do that. When I open the function I get the following first lines:
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;
The function input is not defined just as varargin, as it is done in function surf for example, so it is not possible to specify the axis handle as first input variable. If the axis handle is specified as second input variable, the function axescheck recognize the handle, but later I get an error because the expected second input variable is a vector. If the axis handle is specified as third input variable the function axescheck does not recognize the handle at all.
I know that I can first activate the axis and then call trisurf, but I have this inside a loop so it is not advisable to do that. Is there any other solution?
0 件のコメント
回答 (2 件)
John Bass
2023 年 1 月 8 日
Since this is still unanswered:
trisurf creates a Patch object, which like most graphical objects, has a Parent property.
% ax1 is the handle of you first axis
trisurf(k, x, y, z, 'Parent', ax1)
0 件のコメント
Salvatore Ferrone
2019 年 4 月 9 日
I also have this question. I have four axes. Every time I try to update axes 1, 2, or 3, instead axes4 is updated. I am trying
vcol = 1;
gca = handles.axes1;
cla(handles.axes1)
axis(handles.axes1)
trisurf(spotMap.facetverts, spotMap.verts(:,1), spotMap.verts(:,2),...
spotMap.verts(:,3), spotMap.val(:,vcol), 'EdgeColor','none');
but this does not work. This will still plot on axes4.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!