Plot multiple contours in 3D without volume data

5 views (last 30 days)
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.

Accepted Answer

Daniel
Daniel on 14 Sep 2021
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

More Answers (1)

darova
darova on 5 Sep 2021
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 Comment
Daniel
Daniel on 14 Sep 2021
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.

Sign in to comment.

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!