How do I turn of thr grid of a surface but keep the edge line on?

조회 수: 1 (최근 30일)
Carolin Bock
Carolin Bock 2020년 8월 4일
댓글: Bruno Luong 2020년 8월 4일
Hello,
is it possible to turn of the grid of a surface plot, but keep the edge on?
If I do this, I have no grid and no edge:
Z1 = (0.5 .*(a1.*exp(-b1.*X1)+ e1.*exp(-f1.*X1))-c1.*exp(-d1.*X1)).*Y1.^2 +0.5.*(a1.*exp(-b1.*X1)-e1.*exp(-f1.*X1)).*Y1+c1.*exp(-d1.*X1)
s = surf(X1,Y1,Z1,'FaceColor',[0.1 0.0 1.0],'FaceAlpha',0.8,'EdgeColor', 'black','LineStyle','none', 'EdgeAlpha',0.2,'FaceLighting','flat')
hold on;
If I do this, I have a grid and an edge line:
Z1 = (0.5 .*(a1.*exp(-b1.*X1)+ e1.*exp(-f1.*X1))-c1.*exp(-d1.*X1)).*Y1.^2 +0.5.*(a1.*exp(-b1.*X1)-e1.*exp(-f1.*X1)).*Y1+c1.*exp(-d1.*X1)
s = surf(X1,Y1,Z1,'FaceColor',[0.1 0.0 1.0],'FaceAlpha',0.8,'EdgeColor', 'black','LineStyle','-', 'EdgeAlpha',0.2,'FaceLighting','flat')
hold on;
Thank you:)

채택된 답변

KSSV
KSSV 2020년 8월 4일
[X,Y] = meshgrid(1:10) ;
Z = sqrt(X.^2+Y.^2) ;
% plot the outer line
X1 = X ; X1(2:end-1,2:end-1) = NaN ;
Y1 = Y ; Y1(2:end-1,2:end-1) = NaN ;
Z1 = Z ; Z1(2:end-1,2:end-1) = NaN ;
surf(X,Y,Z)
shading interp
hold on
plot3(X1,Y1,Z1,'k*')
  댓글 수: 2
Carolin Bock
Carolin Bock 2020년 8월 4일
This works perfectly, thanks!!:)
Bruno Luong
Bruno Luong 2020년 8월 4일
편집: Bruno Luong 2020년 8월 4일
until you want to plot a continuous edge boundary.

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

추가 답변 (1개)

Bruno Luong
Bruno Luong 2020년 8월 4일
Just serve yourself with plot3 commands
[X,Y,Z] = peaks;
surf(X,Y,Z,'edgecolor','none');
hold on
plot3(X(1,:),Y(1,:),Z(1,:),'k','LineWidth',2)
plot3(X(end,:),Y(end,:),Z(end,:),'k','LineWidth',2)
plot3(X(:,1),Y(:,1),Z(:,1),'k','LineWidth',2)
plot3(X(:,end),Y(:,end),Z(:,end),'k','LineWidth',2)
  댓글 수: 3
Carolin Bock
Carolin Bock 2020년 8월 4일
Is it possible to change the line color?
Bruno Luong
Bruno Luong 2020년 8월 4일
Just replace 'k' with the color you want.

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

카테고리

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