surf plot behaves strange!

15 次查看(过去 30 天)
Miro
Miro 2012-6-15
Hi,
i generate a surface with surf. The problem is, that the coloring does not match the actual Data.
The Data is shown by the Z-Value in the surface (as usual). I uploaded the created Image. There i pointed out what i mean exactly:
How can the same color be attached to such different z-values?Is this a bug? Has anybody an idea how i can fix this?
Thanks for the attention

回答(2 个)

Kevin Holst
Kevin Holst 2012-6-15
Surf attaches a color to a face based on one point on that face, and each face will be created by 4 points, so that color may not make sense for 3 of those points. This is especially true when there is a lot of variation point to point.
What I typically do is set shading to interp either within the call to surf itself or after the call.
  2 个评论
Miro
Miro 2012-6-18
You say that one color possibly makes no sense for the points, but how can they then be displayed correctly when i do not use the meshgrid (top picture in the link?
Includeing shading interp makes it even worse, cause it takes the colors, which already seem to be interpolated (pic 2 and 3) as basis.
Kevin Holst
Kevin Holst 2012-6-18
Your top picture shows surf(data) which plots each data sample versus its row/column numbers. So your data matrix must be something close to size of 50x560. The reason that when you use meshgrid, you're getting a different looking plot is because it appears that there aren't 560 distinct values in the y-direction. It appears that some are repeated due to the resolution of your y-variable.
One color makes sense (programatically) for those two points you show because of how the surf function attaches a color to a surface face by default. It requires 4 points to make a face, and it chooses 1 of those 4 points to base the color of the face on.

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2012-6-15
The colors of a surf() plot or a pcolor() plot are not directly derived from the Z value of individual points. Instead they are interpolated from nearby points. See http://www.mathworks.com/help/techdoc/ref/surf.html under "Algorithms"
  2 个评论
Kevin Holst
Kevin Holst 2012-6-15
What you described is what happens when using shading interp, which is not the default. The default is faceted in which "each mesh line segment and face has a constant color determined by the color value at the endpoint of the segment or the corner of the face that has the smallest index or indices.'
http://www.mathworks.com/help/techdoc/ref/shading.html
Miro
Miro 2012-6-18
exactly. And this works fine if i plot the data without a specified meshgrid. But when i use the dimensioned grid, the problem occurs. The y-Axis is a time vector, and the time is not continuous, could that possibly be the reason?

请先登录,再进行评论。

类别

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