Help with 3D contours aligned to discrete surface data

조회 수: 2 (최근 30일)
Brantosaurus
Brantosaurus 2022년 10월 11일
댓글: Star Strider 2022년 10월 11일
Running the included code produces the included plot.
Basically a 3D plot of Z along a non-equi-spaced orthogonal mesh in x and y. It generates 3D contours, but they do not lie on the surface. Most are hidden on the reverse side.
Close inspection suggests they appear to lie on a 'smoothed' invisible surface offset from coloured surface. I'm obviously missing something, but if possible, i wish to have black contour lines aligned with the colour interpolated surface.
Data;
figure()
surf(pc,of,c,...
'LineStyle','-',...
'EdgeColor',[0.5 0.5 0.5],...
'FaceColor','interp')
zmin=min(c(:));
zmax=max(c(:));
xlabel 'P_c [bar]'
ylabel '(o/f)_m'
zlabel '{\rho} [kg/m^3]'
set(gca,'xscale','log','yscale','log')
hold on
number=20;
range=zmax-zmin;
inct=range/number;
contourl=zmin:inct:zmax;
contour3(pc,of,c,...
contourl,...
'k')
hold off
colormap (jet(256))
colorbar

채택된 답변

Star Strider
Star Strider 2022년 10월 11일
Reading the files is not an option, so I went straight for the ‘Problem.fig’ file.
I’m not certain that the contour lines aren’t plotting on the surface, however they appear to be the same colours as the surface, and that may be hiding them. One option is to make the surface slightly more transparent, and perhaps also to make the lines black (however the line colour does not appear to change) —
F = openfig(websave('Problem','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1152063/Problem.fig'));
getF = get(F);
Ax = findobj(F, 'Type','Axes');
getAx = get(Ax);
Kids = Ax.Children
Kids =
2×1 graphics array: Contour Surface
Kids(2).FaceAlpha = 0.75; % Necessary (Experiment With Different Values)
hc = Kids(1);
hc.LineWidth = 2; % Optional
hc.LineColor = 'k'; % Optional
I tried a few other experiments, however this is the only one that appears to work reliably.
.
  댓글 수: 8
Brantosaurus
Brantosaurus 2022년 10월 11일
I can live with that.
Thanks very much for your help on this.
Much appreciated.
Star Strider
Star Strider 2022년 10월 11일
As always, my pleasure!
I wish there was a better (at least a more robust) solution.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

커뮤니티

더 많은 답변 보기:  ThingSpeak 커뮤니티

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by