How to make space underneath the lines white opaque in 3D plot?

조회 수: 3 (최근 30일)
Gabriel Maia
Gabriel Maia 2018년 7월 21일
답변: Star Strider 2018년 7월 21일
I need to fill below the lines in opaque white so that it does not show lines behind. I tried to use the surf command but it does not work.
Here is my code until now:
[xn,yn] = meshgrid(linspace(0,0.5,14),linspace(-15,15,100));
zn = exp(-2*yn.^2).*xn;
xn = xn(:);
yn = yn(:);
zn = zn(:);
%%%%%%%%%%%%%%%%%%%%
index = find(diff(yn)<0);
zn(index) = nan;
%%%%%%%%%%%%%%%%%%%%%
len = index(1);
index = [0;index]+1;
index = index(1:2:end); % every 3rd line -- change to select how many lines to plot
elems = ((0:len) + index).'; % implicit singleton expansion
elems = elems(:);
xn = xn(elems);
yn = yn(elems);
zn = zn(elems);
plot3(xn,yn,zn)
set(gca,'ylim',[-10,10],'zlim',[0,2]);
box off
campos([-2.3393; -134.9790; -2.2455])

채택된 답변

Star Strider
Star Strider 2018년 7월 21일
A relatively simple way is to use the patch function:
[xn,yn] = meshgrid(linspace(0,0.5,14),linspace(-15,15,100));
zn = exp(-2*yn.^2).*xn;
figure
patch(xn,yn,zn,'w', 'EdgeColor','none')
hold on
plot3(xn,yn,zn,'b')
hold off
set(gca,'ylim',[-10,10],'zlim',[0,2]);
box off
campos([-2.3393; -134.9790; -2.2455])
view(45,15)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by