Plot multiple contours in 3D without volume data

4 次查看(过去 30 天)
I am trying to plot multiple contours in the same 3D plot without volume data. The resulting plot would look like a slice plot with, for example, two orthogonal planes each showing a contour. Instead, I have data for two different contours that I would like to put in the same 3D plot orthogonal to each other. I have seen answers that allow you to plot multiple contours in 3D if you have volume data (contourslice or slice) or to plot multiple 2D lines in 3D using plot3, but I haven't seen version that can do what I'm looking for.

采纳的回答

Daniel
Daniel 2021-9-14
The key is use of hgtransform. Here's a snippet that hopefully provides enough info.
hold on
ax = gca; % get the current axis
HG = hgtransform(ax); % make it a transform object
[~,h] = contourf(xm_xz/D, zm_xz/D, curly, vlevels, 'LineStyle','none', 'Parent', HG);
% make a plot using the transform object
HG.Matrix = makehgtform('xrotate', pi/2); % rotate it
Z_level = -8/D - 27/D;
h.ContourZLevel = Z_level;
[~,h] = contourf(xm/D,ym/D,curlz, vlevels,'LineStyle','none'); % next plot
countour_height = 31.5/D+0.5;
h.ContourZLevel = +countour_height; % move the last plot
hold off

更多回答(1 个)

darova
darova 2021-9-5
You can use surf
t = linspace(0,2*pi,50);
[x1,y1] = pol2cart(t,1+0.1*sin(5*t)); % first contour
[x2,y2] = pol2cart(t,1); % second contour
[x3,y3] = pol2cart(t,0.5); % third contour
v0 = x1*0;
X = [v0; x1; x2; x3; v0]; % contantenate
Y = [v0; y1; y2; y3; v0];
Z = [v0; v0; v0+1; v0+2; v0+2];
surf(X,Y,Z,'facecolor','r','edgecolor','none')
line([x1 nan x2 nan x3],...
[y1 nan y2 nan y3],...
[v0 nan v0+1 nan v0+2], 'linewidth',2)
light
  1 个评论
Daniel
Daniel 2021-9-14
Unless the facecolor can use another vector so you're plotting a quantity on the surface, this is not what I meant. A colleague figured it out. See answer below.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Contour Plots 的更多信息

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by