How do I get rid of lines on a surf command? Also how do I change the surf to green rather than the default gradient colours?

조회 수: 378 (최근 30일)
I am doing my University dissertation and I want rid of the lines that appear on the surface created by the surf command 'surf(xp,yp,zp)'. I have tried 'LinesVisible = FLASE' but it keeps coming up saying that the '=' is not correct. I also want to turn the surface of this plot to green.
Any help would be amazing. Am not the best on Matlab. I can send my code if that helps anyone.
Thanks Grant

채택된 답변

John D'Errico
John D'Errico 2015년 4월 15일
Yes, but you should realize that 'LinesVisible = FLASE' (despite the misspelling of false) is not even standard syntax in MATLAB for property/value pairs. So you might spend some time familiarizing yourself with that syntax.
You might try the property/value pair: 'edgecolor','none'
I think that is the proper one to kill the lines. Or you can be completely lazy, and just do what I do. So use the command
shading interp
which kills off the lines. Of course, it also causes the shading to be smoother, since it is now interpolated.
If you want the surface to be green, you can use a colormap that will give you shades of green.
surf(peaks(20))
colormap summer
shading interp
Or, you can just set the color to be a boring, flat, greenish hue.
h = surf(peaks(50));
set(h,'edgecolor','none','facecolor',[.1 .9 .1])
I would guess that this would usually not make people happy, since it is difficult to visualize the shape. Those edges really do help on a mono-color surface.
set(h,'edgecolor','r','facecolor',[.1 .9 .1])
  댓글 수: 7
Lucas_Mathijssen
Lucas_Mathijssen 2021년 10월 21일
As an intermediate solution: I noticed that if you still want the edges - just not so pronounced that they polute your image too much - then you could also reduce the edge thickness by useing a property combination like:
set(h, 'EdgeAlpha',0.3)

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

추가 답변 (3개)

pfb
pfb 2015년 4월 15일
편집: pfb 2015년 4월 15일
It seems to me that you're guessing the syntax here. Better go through the handles.
h = surf(xp,yp,zp)
get(h)
gives you all the attribute of your surface.
You want linestyle and color
set(h,'linestyle','none','facecolor',[0 .7 0]);
and add some light
light
  댓글 수: 6
Grant V
Grant V 2015년 4월 15일
Is there a way to get the light to stay coming in from one side even if I rotate the viewing angle of the surface?
pfb
pfb 2015년 4월 15일
Interesting... I'm not sure. Perhaps "camlight" instead of "light". Take a look into the documentation "doc camlight"

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


Roman Kuc
Roman Kuc 2019년 5월 29일
Matlab (and Octave) work faster if the 2D mesh array is pre-allocated. This is typically done by M = zeros(nrows,ncols). I found the grid lines annoying and removed them by preallocating with M = 0.01*ones(nrow,ncols) to remove any zero values that seem to cause the problem.

Kaicheng Zhang
Kaicheng Zhang 2022년 8월 29일
trisurf(F,V(:,1),V(:,2),V(:,3),seg,'FaceColor','flat','EdgeColor','none');

카테고리

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