フィルターのクリア

How to make a symmetric plot with surf?

7 ビュー (過去 30 日間)
Germán Capuano
Germán Capuano 2012 年 7 月 3 日
コメント済み: Christian Veenstra 2015 年 4 月 23 日
Hello, I'm trying to use surf to plot some results and I'm having some problems.
The result is symmetric, but the colors are totally wrong. I know It's because it takes the points of only one corner instead of the average of the four, but it doesn't look good at all.
I don't want to use a blended color because then I can't export it as vectorial drawing (the eps will contain a drawing inside).
If someone can tell me how to solve this problem I would appreciate it very much. Thank you.
  1 件のコメント
Christian Veenstra
Christian Veenstra 2015 年 4 月 23 日
I have the same (or at least similar) problem... there are some answers/comments here, but I think they miss the issue. Hopefully I can clarify it here to highlight the problem.
My initial problem stemmed from the fact that Matlab's surf colours each face based on the value of one of the vertices, not (for example) some interpolation of the vertices. For example:
[X,Y]=meshgrid(-4:4);
Z=zeros(size(X));
Z(5,5)=1;
surf(X,Y,Z);
view(0,90);
Looks pretty non-symmetric, with only the faces up and to the right of the non-zero vertex coloured. Ok, so I read the documentation on surf and choose some better options:
surf(X,Y,Z,'FaceColor','interp');
view(0,90);
Somewhat better, but it is still not symmetric - one diagonal looks different than the other. How this adds a non-physical representation of the underlying data is even more obvious if you plot, say, a checkerboard:
for i=1:length(Z(:))
Z(i)=rem(i,2);
end
surf(X,Y,Z,'FaceColor','interp');
Looks like diagonal troughs! But the underlying data has no reason to prefer that diagonal. So it appears that surf is not symmetric...
Fundamentally it seems there is the problem that Matlab must draw a face between 4 vertices. Of course, you can't (necessarily) draw a square between 4 points - what if they are not co-planar? Matlab chooses to solve this problem by dividing the square into 2 triangular faces along the diagonal (in this case the diagonal from i,j to i+1,j+1); it could just as well have picked the other diagonal (i,j to i-1,j+1), but that would also be non-symmetric.
Ideally I think that Matlab would create a phantom vertex in the middle of the 4 known points, which would be an average of the 4. It could then draw 4 triangular faces, and the result would be have the same symmetry as the underlying data.
Are there any options to make Matlab do something like this, or something equivalently symmetric? It seems like there should be some way to do this automatically (or perhaps it should even be default).

サインインしてコメントする。

回答 (3 件)

Kevin Claytor
Kevin Claytor 2012 年 7 月 4 日
What do you mean by symmetric? Can you post an image? Also, the surf function will allow you to use a custom color value for the points; "surf(X,Y,Z,C)" where 'C' is the color values for each point, so you could compute a color value based on the 4 neighbors and use that.

Luffy
Luffy 2012 年 7 月 4 日
編集済み: Walter Roberson 2012 年 7 月 4 日
Maybe symmetric means his plot looks symmetric and about that eps part for making those hidden regions which appear in your eps plot to disappear you can use entire plot of same color, in surf(X,Y,Z,C).

Marco Medina
Marco Medina 2012 年 7 月 8 日
Hello, i just have this problem, i found something that really help me. There are two ways of see it.
1. Go to the figure of the surf, and open the Property editor from the menu view, in this places, select the axes and go to the button faces of the property editor, then choose the second option (Blended).
2. If you are working in a GUI go to the code an add something like this:
surf('handles.axes1,X,Y,Z,...
'FaceColor','interp')
I hope that it help to you, and sorry , my english is not very good.

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by