create a mesh from the "scatter3" command
17 次查看(过去 30 天)
显示 更早的评论
Is it possible to create a mesh from the "scatter3" command (and keep the colors on the mesh) ?
0 个评论
回答(1 个)
Walter Roberson
2020-12-27
Yes, it is possible. If you record the handle of the scatter3(), then you can fetch the XData, YData, ZData and CData properties to give the coordinates of the points (but it would have been easier to just use the expressions you passed to scatter3() )
Once you have the coordinates, you can use https://www.mathworks.com/help/matlab/ref/delaunay.html delaunay() to produce a triangulation. You can then trimesh() to plot it:
T = delaunay(x, y, z);
h = trimesh(T, x, y, z, c, 'FaceColor', 'none');
2 个评论
Walter Roberson
2020-12-27
Perhaps you should describe the difference between what you wanted and what you obtained. Attaching data and sample plots would help.
Note: it is common that when you have scattered points in 3 space that triangulation ends up joining what you are thinking of as being in different "layers". It is also common for points to end up joined across ends of a curve when you are only expecting joining along the curve.
Remember that the order of points in scatter3 does not give any information about how the points are joined. If you have information about how the points are joined, then you should use that information instead of fetching information from scatter3.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!