Mesh plot with only every nth line plotted?

4 次查看(过去 30 天)
Hello,
is it possible to reduce the number of plotted lines in a mesh-plot without loss of accuracy? I know, I can reduce the number of data points. But in this case the accuracy of the mesh-plot gets quite bad (see exsample below). Is there any way to say "mesh" to show only every nth line of the wireframe?
% [Matlab]
[DataX,DataY,DataZ] = peaks(100);
subplot(1,2,1);
mesh(DataX,DataY,DataZ,'EdgeColor','k');
subplot(1,2,2);
mesh(DataX(1:10:end,1:10:end),DataY(1:10:end,1:10:end),...
DataZ(1:10:end,1:10:end),'EdgeColor','k');
% [/Matlab]
Best regards
Guido
[Edit] Really bad mistake in writing corrected. [/Edit]

采纳的回答

Mike Garrity
Mike Garrity 2014-10-10
There isn't a nice automatic way to do it, but it's not too hard. You need 3 surfaces. One for the white background, one for the row edges, and one for the column edges. It would look something like this:
rskip = round(linspace(1,size(DataZ,1),32));
cskip = round(linspace(1,size(DataZ,2),32));
surf(DataX,DataY,DataZ,'FaceColor','white','EdgeColor','none');
hold on
surf(DataX(rskip,:),DataY(rskip,:),DataZ(rskip,:),'FaceColor','none','MeshStyle','row');
surf(DataX(:,cskip),DataY(:,cskip),DataZ(:,cskip),'FaceColor','none','MeshStyle','column');
hold off
The reason for this is that you want to reduce the resolution between edges, but not along edges.
  1 个评论
Guido
Guido 2014-10-10
Hello Mike,
yes, the trick is the first white surface. I already tried the other steps but I wasn't successful because of the missing white surface. Thank you very much.
% [Matlab]
[DataX,DataY,DataZ] = peaks(100);
subplot(1,2,1);
mesh(DataX,DataY,DataZ,'EdgeColor','k');
subplot(1,2,2);
rskip = round(linspace(1,size(DataZ,1),32));
cskip = round(linspace(1,size(DataZ,2),32));
surf(DataX,DataY,DataZ,'FaceColor','white','EdgeColor','none');
hold on
surf(DataX(rskip,:),DataY(rskip,:),DataZ(rskip,:),'FaceColor','none','MeshStyle','row');
surf(DataX(:,cskip),DataY(:,cskip),DataZ(:,cskip),'FaceColor','none','MeshStyle','column');
% [/Matlab]
Best regards
Guido

请先登录,再进行评论。

更多回答(1 个)

Thorsten
Thorsten 2014-10-10
If you reduce the number of lines the plot will usually be less accurate, unless in special cases where you have, e.g., a plane. The only thing you can do is to find a compromise between accuracy and line number that fits your needs.

类别

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